/** * 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()); }
/** * Adds single-line text input control used for sensitive input such as passwords. * @param string control name * @param string label * @param int width of the control (deprecated) * @param int maximum number of characters the user may enter * @return Nette\Forms\Controls\TextInput */ public function addPassword($name, $label = NULL, $cols = NULL, $maxLength = NULL) { $control = new Controls\TextInput($label, $maxLength); $control->setAttribute('size', $cols); return $this[$name] = $control->setType('password'); }
/** * Adds single-line text input control used for sensitive input such as passwords. * @param string control name * @param string label * @param int width of the control (deprecated) * @param int maximum number of characters the user may enter * @return Nette\Forms\Controls\TextInput */ public function addPassword($name, $label = NULL, $cols = NULL, $maxLength = NULL) { $control = new Controls\TextInput($label, $maxLength); if ($cols) { trigger_error(__METHOD__ . '() third parameter $cols is deprecated, use setAttribute("size", ...).', E_USER_DEPRECATED); $control->setAttribute('size', $cols); } return $this[$name] = $control->setType('password'); }
/** * Adds single-line text input control used for sensitive input such as passwords. * * @param string control name * @param string label * @param int width of the control * @param int maximum number of characters the user may enter * * @return Nette\Forms\Controls\TextInput */ public function addPassword($name, $label = null, $cols = null, $maxLength = null) { $control = new Controls\TextInput($label, $cols, $maxLength); $control->setType('password'); return $this[$name] = $control; }