public function renderEdit() { $value = $this->_input->getValue(); $html =& new xmlElement('input'); $html->setAttribute('type', 'checkbox'); $html->setAttribute('name', $this->_input->getInputName()); if (!FormInput::hasUserInput()) { if (is_null($value)) { $value = $this->_input->getDefaultValue(); } } if (!is_null($this->_input->getConfiguration())) { if (!FormInput::hasUserInput()) { $configSelected = $this->_input->getConfiguration()->getConfig(FormInputEnumeration::CONFIG_TYPE_SELECTED); if (!is_null($configSelected) && $configSelected->isSelected()) { $html->setAttribute('checked', 'checked'); } } else { if (!is_null($value)) { $html->setAttribute('checked', 'checked'); } } } $html->setAttribute('value', htmlspecialchars($value)); return (string) $html; }
public function __construct(array $options = array()) { if (!isset($options['bound'])) { $options['bound'] = false; } parent::__construct($options); }
protected function __construct($Type, $Attribs = array()) { $this->Code .= parent::getPend1($Attribs); $this->Code .= '<input type="' . $Type . '"' . parent::parseAttribs($Attribs) . ' />'; $this->Code .= parent::getPend2($Attribs); $this->Attribs = $Attribs; }
public function buildOpenTag() { unset($this->attributes['name']); unset($this->attributes['value']); unset($this->attributes['type']); return parent::buildOpenTag(); }
public function __construct(array $options = array()) { if (!function_exists('recaptcha_get_html')) { require Misc::getLibPath() . '/vendors/recaptcha/recaptchalib.php'; } parent::__construct($options); }
protected function build($Label, $Attribs) { $this->Code .= '<button '; $this->Code .= parent::parseAttribs($Attribs); $this->Code .= '>' . $Label . '</button>'; $this->Attribs = $Attribs; }
public function __construct($Attribs = array()) { $this->Code .= parent::getPend1($Attribs); $this->Code .= '<input type="password"' . parent::parseAttribs($Attribs) . ' />'; $this->Code .= parent::getPend2($Attribs); $this->Attribs = $Attribs; }
function __construct($value = '', $name = null) { $load = new Loader(); $this->date_picker = $load->customFormComponent('/widgets/datepicker'); $this->dropdown = Loader::formComponent('dropdown'); parent::__construct('hidden', $value, $name); }
public function __construct($Attribs = array()) { $this->Code .= '<input type="file"'; $this->Code .= parent::parseAttribs($Attribs); $this->Code .= ' />'; $this->Attribs = $Attribs; }
/** * Display the value of the input * * @return string The displayed HTML or text */ public function display() { if ($this->plainText) { $this->value = nl2br($this->value); } return parent::display(); }
/** * Display the checkbox * * @return string The displayed HTML */ public function display() { if ($this->value) { $this->checked = true; } return parent::display(); }
function __toString() { if ($this->_checked) { $this->setAttribute('checked', 'checked'); } $this->setAttribute('value', $this->_value); return parent::__toString(); }
public static function getInput($inputInfo, $type = 'text') { if (method_exists('FormInput', $type) && FormInput::validateInputInfo($inputInfo)) { return call_user_func(array('FormInput', $type), $inputInfo); } else { throw new Exception("Bad parameters."); } }
function __toString() { $maxlength = $this->_validator != null ? $this->_validator->getOption('max_length') : null; if ($maxlength !== null) { $this->setAttribute('maxlength', $maxlength); } return parent::__toString(); }
/** * Display the input * * @return string The HTML result to display */ public function display() { if (empty($this->value)) { $this->value = "{}"; } elseif (is_array($this->value)) { $this->value = json_encode($this->value, JSON_NUMERIC_CHECK | JSON_HEX_APOS | JSON_HEX_QUOT); } return parent::display(); }
/** * Display the input * * @return string The HTML result of displaying */ public function display() { if (is_numeric($this->value)) { $this->timestamp = $this->value; } else { $this->timestamp = strtotime($this->value); } $this->value = $this->timestamp ? date(self::FORMAT, $this->timestamp) : ''; return parent::display(); }
/** * Initializes a radio button * * @param string $Label Text associated with the button * @param array $Attribs * @param bool $Inline If true, appears on the same line as other radio buttons in the same group */ public function __construct($Label = '', $Attribs = array(), $Inline = false) { $this->Code .= '<label class="radio'; if ($Inline) { $this->Code .= ' inline'; } $this->Code .= '"><input type="radio"'; $this->Code .= parent::parseAttribs($Attribs); $this->Code .= ' />' . $Label . '</label>'; $this->Attribs = $Attribs; }
/** * @brief Instancie et retourne un �l�ment de formulaire * @param $enum_const const \ref FormInputType * @param $input_name string Nom de l'�l�ment * @return FormInput * @throw Exception */ public static function createNew($enum_const, $input_name) { $rv = null; if (FormInputEnumeration::TYPE_TEXT == $enum_const) { System::import('System.FormInput.Inputs.TextField'); $rv =& new TextField($input_name); } elseif (FormInputEnumeration::TYPE_CHECKBOX == $enum_const) { System::import('System.FormInput.Inputs.Checkbox'); $rv =& new Checkbox($input_name); } if (!is_null($rv)) { FormInput::registerItem($rv); } return $rv; }
public function morph() { foreach ($this->inputs as $key => $input) { if (!$input instanceof FormInput) { $input = new FormInput($input); } foreach ($this->styles as $style => $v) { if ($input->isAllowedStyle($style)) { $input->getTag()->setStyle($style, $v); } } if ($this->getOption('wrap', TRUE)) { $wrapper = HTML::tag('div', new \stdClass(), array('class' => 'input-set-wrapper')); $wrapper->content->input = $input; $wrapper->content->input->morph(); $this->elements[$key] = $wrapper; } else { $input->morph(); $this->elements[$key] = $input; } } $this->morphed = TRUE; return $this; }
/** * Check the submitted value * * @param Form $form The form this input is associated to * * @return bool True if the input format is correct, else False */ public function check(&$form = null) { if (parent::check($form)) { // Check the confirmation password if (!empty($this->compare) && $form) { if ($this->value != $form->getData($this->compare)) { $form->error($this->errorAt, Lang::get('form.password-comparison')); return false; } } return true; } else { return false; } }
/** * Create a selection input field. * * @option 'postback' if true it will submit the form when changed. * @option 'selected' forces key to be selected. */ public function __construct($key, $id, $name, $value, $label = null, array $attr = []) { /* if postback is enabled, add onchange which submits the forrm */ if ($this->popAttr('postback', $attr, $postback) && $postback) { $attr['onchange'] = 'this.form.submit();'; } $this->selected = $value; $this->popAttr('selected', $attr, $this->selected); $this->popAttr('options', $attr, $this->options); /* fill with empty options */ if ($this->options === null) { $this->options = new FormOptions(); } parent::__construct($key, $id, $name, $value, null, $label, $attr); /* FormInput sets value which select shouldn't have */ unset($this->attr['value']); }
/** * Initializes the select * * @param array $Options Available options for the input * @param null|array $Selected The default selected option. Can be a single option or an array of options. Options start with an index of 0 * @param array $Attribs */ public function __construct($Options = array(), $Selected = null, $Attribs = array()) { $this->Code .= '<select'; $this->Code .= parent::parseAttribs($Attribs); $this->Code .= '>'; //Convert $Selected to array if necessary if (!is_array($Selected)) { $Selected = (array) $Selected; } foreach ($Options as $key => $val) { $this->Code .= '<option value="' . $key . '"'; if (in_array($key, $Selected, true)) { $this->Code .= ' selected'; } $this->Code .= '>' . $val . '</option>'; } $this->Code .= '</select>'; $this->Attribs = $Attribs; }
/** * {@inheritdoc} */ public function getData($name = null) { $request = $this->request; $dataSrc = 'request'; switch (strtolower($request->getMethod())) { case 'get': return parent::getData($name); break; } $json = $this->request->getContent(); $data = @json_decode($json, true); if ($name !== null && isset($data[$name])) { $data = $data[$name]; } if (!is_array($data)) { $data = []; } return $data; }
public function renderEdit() { $value = $this->_input->getValue(); $html =& new xmlElement('input'); $html->setAttribute('type', 'text'); $html->setAttribute('name', $this->_input->getInputName()); if (!FormInput::hasUserInput()) { if (is_null($value)) { $value = $this->_input->getDefaultValue(); } } if (!is_null($this->_input->getConfiguration())) { if (!FormInput::hasUserInput()) { $configSelected = $this->_input->getConfiguration()->getConfig(FormInputEnumeration::CONFIG_TYPE_LENGTH); if (!is_null($configSelected)) { $html->setAttribute('maxlength', $configSelected->getMaxLength()); } } } $html->setAttribute('value', $value); return (string) $html; }
public function generate() { $code = '<textarea'; // adding attributes foreach ($this as $key => $value) { // some object properties shouldn't be added as HTML attributes $dont = array('value', 'trim', 'label', 'labelNote'); if (in_array($key, $dont)) { continue; } // appending attribute $key = strtolower($key); if (is_string($value) || is_int($value) || is_float($value)) { $code .= ' ' . $key . '="' . $value . '"'; } elseif ($value === true) { $code .= ' ' . $key; } } // value $code .= '>' . htmlspecialchars($this->value) . '</textarea>'; return parent::generate($code); }
/** * Check the submitted value of the input * * @param Form $form The form the input is associated with * * @return bool True if the submitted value is valid, else false */ public function check(&$form = null) { // Start by checking general validators if (parent::check($form)) { if (!empty($this->value) && !is_numeric($this->value)) { // The value is not numeric $form->error($this->errorAt, Lang::get('form.number-format')); return false; } elseif (isset($this->minimum) && $this->value < $this->minimum) { // The value is lower than the given minimum $form->error($this->errorAt, Lang::get("form.number-minimum", array('value' => $this->minimum))); return false; } elseif (isset($this->maximum) && $this->value > $this->maximum) { // The value is greater than the given maximum $form->error($this->errorAt, Lang::get("form.number-maximum", array('value' => $this->maximum))); return false; } // The value is valid return true; } else { return false; } }
public function __construct($name, $label = '', &$oForm = Null) { parent::__construct($name, $label); $this->attrs['type'] = 'file'; $this->autoBound(False); if (substr($this->getName(), -2) == '[]') { $this->expect_array = True; } if (is_null($oForm) or !$oForm instanceof Form) { trigger_error('Une instance du formulaire doit être passée comme troisième paramètre au champ « ' . $name . ' ».', E_USER_ERROR); } //on adapte le form $this->form = $oForm; $this->form->setEnctype('multipart/form-data'); //définition des erreurs $this->setErrorText('invalid_ext', 'L\'extension du fichier n\'est pas valide. Extensions autorisées : %s'); $this->setErrorText('too_big', 'Le fichier est trop volumineux (%d octets max)'); $this->setErrorText('too_many_files', 'Trop de fichiers ont été soumis. Nombre maximal : %d'); $this->setErrorText('not_enough_files', 'Pas assez de fichiers ont été soumis. Nombre minimal : %d'); }
function __construct($value = "Reset", $name = null) { parent::__construct('reset', $value, $name); }
function __toString() { $this->setAttribute('src', UrlHelper::resource($this->src)); return parent::__toString(); }
/** * Display the color input * * @return string the displayed HTML */ public function display() { $this->type = "text"; return parent::display(); }