isRequired() public method

Is control mandatory?
public isRequired ( ) : boolean
return boolean
Ejemplo n.º 1
0
 public static function label(Html $label, BaseControl $control, $isPart)
 {
     if ($label->getName() === 'label') {
         $label->addClass('control-label');
     }
     if ($control->isRequired()) {
         $label->addClass('required');
     }
     return $label;
 }
 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
         $control->setOption('required', TRUE);
     }
     $el = $control->getControlPrototype();
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', Html::el('i class="fa fa-fw fa-envelope"'));
     }
     if ($control->controlPrototype->type === 'password' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', Html::el('i class="fa fa-fw fa-lock"'));
     }
     if ($control instanceof \Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
     } else {
         $control->setOption('pairContainer', $pair = Html::el('div'));
         $pair->id = $control->htmlId . '-pair';
         $pair->addClass('form-group');
         $label = $control->labelPrototype;
         if (static::isCheckbox($control)) {
             $label->addClass('checkbox');
         } elseif (!$control instanceof Controls\RadioList && !self::isCheckboxList($control)) {
             $label->addClass('control-label');
             if (!$control instanceof \Minetro\Forms\reCAPTCHA\ReCaptchaField) {
                 $el->addClass('form-control');
             }
         }
         if ($control->getOption('required', FALSE)) {
             $pair->addClass('required');
         }
         if ($control->errors) {
             $pair->addClass('has-error');
         }
         if ($prepend = $control->getOption('input-prepend')) {
             $prepend = Html::el('span', array('class' => 'input-group-addon'))->{$prepend instanceof Html ? 'add' : 'setText'}($prepend);
             $control->setOption('input-prepend', $prepend);
         }
         if ($append = $control->getOption('input-append')) {
             $append = Html::el('span', array('class' => 'input-group-addon'))->{$append instanceof Html ? 'add' : 'setText'}($append);
             $control->setOption('input-append', $append);
         }
     }
 }
 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
         $control->setOption('required', TRUE);
     }
     $el = $control->getControlPrototype();
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', '@');
     }
     if ($control instanceof Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
     } else {
         $label = $control->labelPrototype;
         if ($control instanceof Controls\Checkbox) {
             $label->addClass('checkbox');
         } elseif (!$control instanceof Controls\RadioList && !self::isCheckboxList($control)) {
             $label->addClass('control-label');
         }
         $control->setOption('pairContainer', $pair = Html::el('div'));
         $pair->id = $control->htmlId . '-pair';
         $pair->addClass('control-group');
         if ($control->getOption('required', FALSE)) {
             $pair->addClass('required');
         }
         if ($control->errors) {
             $pair->addClass('error');
         }
         if ($prepend = $control->getOption('input-prepend')) {
             $prepend = Html::el('span', array('class' => 'add-on'))->{$prepend instanceof Html ? 'add' : 'setText'}($prepend);
             $control->setOption('input-prepend', $prepend);
         }
         if ($append = $control->getOption('input-append')) {
             $append = Html::el('span', array('class' => 'add-on'))->{$append instanceof Html ? 'add' : 'setText'}($append);
             $control->setOption('input-append', $append);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function isRequired()
 {
     return $this->wrappedControl->isRequired();
 }
 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
         $control->setOption('required', TRUE);
     }
     $el = $control->getControlPrototype();
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email' && $control->getOption('input-prepend') === NULL) {
         $control->setOption('input-prepend', '@');
     }
     if ($control instanceof Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
         if ($control->getOption('btn-class') !== NULL) {
             $el->addClass($control->getOption('btn-class'));
         } else {
             $el->addClass('btn-default');
         }
     } else {
         if (static::isTextBase($control) || $control instanceof Controls\SelectBox) {
             $classes = $control->controlPrototype->class;
             if (!is_array($classes)) {
                 $classes = explode(' ', $classes);
             }
             if (($pos = array_search('no-form-control', $classes, TRUE)) !== FALSE) {
                 unset($classes[$pos]);
                 $el->class = $classes;
             } elseif ($control->getOption('noFormControl', FALSE) !== TRUE) {
                 $el->addClass('form-control');
             }
         }
         $label = $control->labelPrototype;
         if (!$control instanceof Controls\Checkbox && !$control instanceof Controls\RadioList && !static::isCheckboxList($control)) {
             $label->addClass('control-label');
         }
         $control->setOption('pairContainer', $pair = Html::el('div'));
         $pair->id = $control->htmlId . '-pair';
         $pair->addClass('form-group');
         if ($control->getOption('required', FALSE)) {
             $pair->addClass('required');
         }
         if ($control->errors) {
             $pair->addClass('has-error');
         }
     }
 }
 /**
  * @param \Nette\Forms\Controls\BaseControl $control
  */
 private function prepareControl(Controls\BaseControl $control)
 {
     $translator = $this->form->getTranslator();
     $control->setOption('rendered', FALSE);
     if ($control->isRequired()) {
         $control->getLabelPrototype()->addClass('required');
     }
     $el = $control->getControlPrototype();
     if ($el->getName() === 'input') {
         $el->class(strtr($el->type, array('password' => 'text', 'file' => 'text', 'submit' => 'button', 'image' => 'imagebutton')), TRUE);
     }
     if ($placeholder = $control->getOption('placeholder')) {
         if (!$placeholder instanceof Html && $translator) {
             $placeholder = $translator->translate($placeholder);
         }
         $el->placeholder($placeholder);
     }
     if ($control->controlPrototype->type === 'email') {
         $email = Html::el('span', array('class' => 'add-on'))->setText('@');
         $control->setOption('input-prepend', $email);
     }
     if ($control instanceof Nette\Forms\ISubmitterControl) {
         $el->addClass('btn');
     }
 }