File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo
6868 /** @var array user options */
6969 private $ options = [];
7070
71+ /** @var bool */
72+ private static $ autoOptional = FALSE ;
73+
7174
7275 /**
7376 * @param string caption
@@ -80,6 +83,9 @@ public function __construct($caption = NULL)
8083 $ this ->label = Html::el ('label ' );
8184 $ this ->caption = $ caption ;
8285 $ this ->rules = new Rules ($ this );
86+ if (self ::$ autoOptional ) {
87+ $ this ->setRequired (FALSE );
88+ }
8389 $ this ->setValue (NULL );
8490 }
8591
@@ -527,6 +533,16 @@ public function cleanErrors()
527533 }
528534
529535
536+ /**
537+ * Globally enables new required/optional behavior.
538+ * This method will be deprecated in next version.
539+ */
540+ public static function enableAutoOptionalMode ()
541+ {
542+ self ::$ autoOptional = TRUE ;
543+ }
544+
545+
530546 /********************* user data ****************d*g**/
531547
532548
You can’t perform that action at this time.
0 commit comments