public function notifyRule(Rule $rule) { if (is_string($rule->operation) && strcasecmp($rule->operation, ':float') === 0) { $this->addFilter(callback(__CLASS__, 'filterFloat')); } parent::notifyRule($rule); }
/** * This method will be called when the component (or component's parent) * becomes attached to a monitored object. Do not call this method yourself. * @param IComponent * @return void */ protected function attached($form) { if ($form instanceof Form) { if ($form->getMethod() !== Form::POST) { throw new \InvalidStateException('File upload requires method POST.'); } $form->getElementPrototype()->enctype = 'multipart/form-data'; } parent::attached($form); }
/** * Generates control's HTML element. * @param string * @return Nette\Web\Html */ public function getControl($caption = NULL) { $control = parent::getControl(); $control->value = $this->translate($caption === NULL ? $this->caption : $caption); return $control; }
/** * Generates label's HTML element. * @param string * @return void */ public function getLabel($caption = NULL) { $label = parent::getLabel($caption); $label->for = NULL; return $label; }
/** * Generates control's HTML element. * @return Nette\Web\Html */ public function getControl() { $control = parent::getControl(); $selected = $this->getValue(); $selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE); $option = Nette\Web\Html::el('option'); foreach ($this->items as $key => $value) { if (!is_array($value)) { $value = array($key => $value); $dest = $control; } else { $dest = $control->create('optgroup')->label($key); } foreach ($value as $key2 => $value2) { if ($value2 instanceof Nette\Web\Html) { $dest->add((string) $value2->selected(isset($selected[$key2]))); } elseif ($this->useKeys) { $dest->add((string) $option->value($key2)->selected(isset($selected[$key2]))->setText($this->translate($value2))); } else { $dest->add((string) $option->selected(isset($selected[$value2]))->setText($this->translate($value2))); } } } return $control; }
/** * Generates control's HTML element. * @return Nette\Web\Html */ public function getControl() { return parent::getControl()->value($this->forcedValue === NULL ? $this->value : $this->forcedValue)->data('nette-rules', NULL); }
public function addRule($operation, $message = NULL, $arg = NULL) { if ($operation === Form::FLOAT) { $this->addFilter(callback(__CLASS__, 'filterFloat')); } return parent::addRule($operation, $message, $arg); }
/** * Generates control's HTML element. * @return Nette\Web\Html */ public function getControl() { $control = parent::getControl(); if ($this->skipFirst) { reset($this->items); $control->data('nette-empty-value', $this->useKeys ? key($this->items) : current($this->items)); } $selected = $this->getValue(); $selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE); $option = Nette\Web\Html::el('option'); foreach ($this->items as $key => $value) { if (!is_array($value)) { $value = array($key => $value); $dest = $control; } else { $dest = $control->create('optgroup')->label($key); } foreach ($value as $key2 => $value2) { if ($value2 instanceof Nette\Web\Html) { $dest->add((string) $value2->selected(isset($selected[$key2]))); } else { $key2 = $this->useKeys ? $key2 : $value2; $value2 = $this->translate((string) $value2); $dest->add((string) $option->value($key2 === $value2 ? NULL : $key2)->selected(isset($selected[$key2]))->setText($value2)); } } } return $control; }
/** * Generates control's HTML element. * @return Nette\Web\Html */ public function getControl() { return parent::getControl()->checked($this->value); }
/** * Generates control's HTML element. * @return Nette\Web\Html */ public function getControl() { return parent::getControl()->value($this->forcedValue === NULL ? $this->value : $this->forcedValue); }
public function notifyRule(Rule $rule) { if (is_string($rule->operation) && !$rule->isNegative) { if (strcasecmp($rule->operation, ':float') === 0) { $this->addFilter(callback(__CLASS__, 'filterFloat')); } elseif (strcasecmp($rule->operation, ':length') === 0) { $this->control->maxlength = is_array($rule->arg) ? $rule->arg[1] : $rule->arg; } elseif (strcasecmp($rule->operation, ':maxLength') === 0) { $this->control->maxlength = $rule->arg; } } parent::notifyRule($rule); }