本文整理汇总了PHP中FormControl::getControl方法的典型用法代码示例。如果您正苦于以下问题:PHP FormControl::getControl方法的具体用法?PHP FormControl::getControl怎么用?PHP FormControl::getControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormControl
的用法示例。
在下文中一共展示了FormControl::getControl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getControl
public function getControl()
{
$control = parent::getControl();
foreach ($this->getRules() as $rule) {
if ($rule->type === Rule::VALIDATOR && !$rule->isNegative && ($rule->operation === Form::LENGTH || $rule->operation === Form::MAX_LENGTH)) {
$control->maxlength = is_array($rule->arg) ? $rule->arg[1] : $rule->arg;
}
}
if ($this->emptyValue !== '') {
$control->data('nette-empty-value', $this->translate($this->emptyValue));
}
return $control;
}
示例2: getControl
/**
* Generates control's HTML element.
* @return Html
*/
public function getControl()
{
$control = FormControl::getControl();
// skopirovany kod z SelectBox.php
if ($this->isFirstSkipped()) {
$items = $this->items;
reset($items);
$control->data['nette-empty-value'] = $this->areKeysUsed() ? key($items) : current($items);
}
$selected = $this->getValue();
$this->selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE);
$this->formatOptions($this->items, $control);
return $control;
}
示例3: getControl
/**
* Generates control's HTML element.
* @param mixed
* @return Html
*/
public function getControl($key = NULL)
{
if ($key === NULL) {
$container = clone $this->container;
$separator = (string) $this->separator;
} elseif (!isset($this->items[$key])) {
return NULL;
}
$control = parent::getControl();
$id = $control->id;
$counter = -1;
$value = $this->value === NULL ? NULL : (string) $this->getValue();
$label = Html::el('label');
foreach ($this->items as $k => $val) {
$counter++;
if ($key !== NULL && $key != $k) {
continue;
}
// intentionally ==
$control->id = $label->for = $id . '-' . $counter;
$control->checked = (string) $k === $value;
$control->value = $k;
if ($val instanceof Html) {
$label->setHtml($val);
} else {
$label->setText($this->translate($val));
}
if ($key !== NULL) {
return (string) $control . (string) $label;
}
$container->add((string) $control . (string) $label . $separator);
unset($control->data['nette-rules']);
// TODO: separator after last item?
}
return $container;
}
示例4: getControl
/**
* Generates control's HTML element.
* @return Nette\Web\Html
*/
public function getControl()
{
$control = parent::getControl();
$control->value = $this->translate($this->caption);
return $control;
}
示例5: getControl
/**
* Generates control's HTML element.
* @return Nette\Web\Html
*/
public function getControl()
{
return parent::getControl()->checked($this->value);
}
示例6: getControl
/**
* Generates control's HTML element.
* @return Html
*/
public function getControl()
{
return parent::getControl()->value($this->forcedValue === NULL ? $this->value : $this->forcedValue);
}
示例7: getControl
/**
* Generates control's HTML element.
* @return Nette\Web\Html
*/
public function getControl()
{
$container = clone $this->container;
$separator = (string) $this->separator;
$control = parent::getControl();
$id = $control->id;
$counter = 0;
$value = $this->value === NULL ? NULL : (string) $this->getValue();
$label = Html::el('label');
foreach ($this->items as $key => $val) {
$control->id = $label->for = $id . '-' . $counter;
$control->checked = (string) $key === $value;
$control->value = $key;
if ($val instanceof Html) {
$label->setHtml($val);
} else {
$label->setText($this->translate($val));
}
$container->add((string) $control . (string) $label . $separator);
$counter++;
// TODO: separator after last item?
}
return $container;
}
示例8: getControl
/**
* Generates control's HTML element.
* @return Html
*/
public function getControl()
{
$control = parent::getControl();
$selected = $this->getValue();
$selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE);
$option = 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 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;
}
示例9: getControl
public function getControl()
{
return parent::getControl()->data('nette-empty-value', $this->emptyValue === '' ? NULL : $this->translate($this->emptyValue));
}
示例10: getControl
/**
* Generates control's HTML element.
* @return Html
*/
public function getControl()
{
return parent::getControl()->value($this->forcedValue === NULL ? $this->value : $this->forcedValue)->data('nette-rules', NULL);
}