Nette\Forms\Controls\SelectBox::setPrompt PHP Method

setPrompt() public method

Sets first prompt item in select box.
public setPrompt ( $prompt ) : self
return self
    public function setPrompt($prompt)
    {
        $this->prompt = $prompt;
        return $this;
    }

Usage Example

Example #1
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;
 }