/**
  * @param IControlConfig $config
  * @return NULL|Controls\MultiChoiceControl
  */
 public function createControl(IControlConfig $config)
 {
     $control = NULL;
     if ($config->getType() === IControlConfig::CHECKBOX_LIST) {
         $control = new Controls\CheckboxList($config->getLabel());
     } elseif ($config->getType() === IControlConfig::MULTI_SELECT) {
         $control = new Controls\MultiSelectBox($config->getLabel());
     }
     // Setup items
     if ($control && ($items = $this->helper->processItems($control, $config)) !== NULL) {
         $control->setItems($items);
     }
     return $control;
 }
示例#2
0
 /**
  * @param IControlConfig $config
  * @return NULL|Controls\ChoiceControl
  */
 public function createControl(IControlConfig $config)
 {
     $control = NULL;
     if ($config->getType() === IControlConfig::RADIO_LIST) {
         $control = new Controls\RadioList($config->getLabel());
     } elseif ($config->getType() === IControlConfig::SELECT) {
         $control = new Controls\SelectBox($config->getLabel());
         $control->setPrompt($config->getOption(IControlConfig::PROMPT) ?: FALSE);
     }
     // Setup items
     if ($control && ($items = $this->helper->processItems($control, $config)) !== NULL) {
         $control->setItems($items);
     }
     return $control;
 }
示例#3
0
 /**
  * Create control from configuration or return NULL if factory does not match config.
  *
  * @param IControlConfig $config
  * @return NULL|BaseControl
  */
 public function createControl(IControlConfig $config)
 {
     if ($config->getType() === IControlConfig::DATE_TIME) {
         $dateFormat = $config->getOption(self::DATE_FORMAT, self::DEFAULT_DATE_FORMAT);
         $control = new DateTimeControl($config->getLabel(), $dateFormat);
         return $control;
     }
     return NULL;
 }
 /**
  * Create control from configuration or return NULL if factory does not match config.
  *
  * @param IControlConfig $config
  * @return NULL|BaseControl
  */
 public function createControl(IControlConfig $config)
 {
     if ($config->getType() === self::TYPE) {
         $control = new CountryAndStateControl($config->getLabel());
         $countryCode = $config->getOption(self::DEFAULT_COUNTRY_CODE, 'US');
         $control->setDefaultCountryCode($countryCode);
         return $control;
     }
     return NULL;
 }
示例#5
0
 /**
  * Create control from configuration or return NULL if factory does not match config.
  *
  * @param IControlConfig $config
  * @return NULL|BaseControl
  */
 public function createControl(IControlConfig $config)
 {
     switch ($config->getType()) {
         case IControlConfig::BUTTON:
             return new Controls\Button($config->getLabel());
         case IControlConfig::CHECKBOX:
             return new Controls\Checkbox($config->getLabel());
         case IControlConfig::EMAIL:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('email');
             return $input;
         case IControlConfig::HIDDEN:
             return new Controls\HiddenField();
         case IControlConfig::PASSWORD:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('password');
             return $input;
         case IControlConfig::SUBMIT:
             return new Controls\SubmitButton($config->getLabel());
         case IControlConfig::TEXT:
             return new Controls\TextInput($config->getLabel());
         case IControlConfig::TEXTAREA:
             return new Controls\TextArea($config->getLabel());
         case IControlConfig::DATE_TIME:
             $input = new Controls\TextInput($config->getLabel());
             return $input;
         case IControlConfig::DATE:
             $input = new Controls\TextInput($config->getLabel());
             return $input;
         case IControlConfig::TIME:
             $input = new Controls\TextInput($config->getLabel());
             return $input;
         case IControlConfig::URL:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('url');
             return $input;
         case IControlConfig::INTEGER:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('number');
             return $input;
         case IControlConfig::FLOAT:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('number');
             $input->setAttribute('step', 'any');
             return $input;
     }
     return new Nette\Forms\Controls\TextInput($config->getLabel());
 }