本文整理汇总了PHP中Zend\Form\ElementInterface::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::setOption方法的具体用法?PHP ElementInterface::setOption怎么用?PHP ElementInterface::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\ElementInterface
的用法示例。
在下文中一共展示了ElementInterface::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* {@inheritDoc}
*/
public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
{
if ($element) {
$element->setOption('input_group', true);
}
return parent::render($content, $attribs, $element, $form);
}
示例2: render
public function render(ElementInterface $element)
{
$name = $element->getName();
if (empty($name) && $name !== 0) {
throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
}
$attributes = $element->getAttributes();
$attributes['name'] = $name;
$content = (string) $element->getValue();
$escapeHtml = $this->getEscapeHtmlHelper();
//ADD OPTIONS
// this should really be in Stjonvisi\Form\Element\Img
// but it gets overwritten at some point, so the simplest
// thing was to add it here.
// TODO place this i a more generic place
$element->setOption('max', $this->getMaxSize())->setOption('mime', '/image\\/jpg|png|gif/')->setOption('url', '/skrar/mynd');
//OPTIONS
// options are used to set attributes and values
// to the custom element. We therefore need to remove
// label, label_attributes and label_options before we
// can convert them into an attribute string.
$options = $element->getOptions();
unset($options['label']);
unset($options['label_attributes']);
unset($options['label_options']);
$strings = array_map(function ($key, $value) {
return sprintf('%s="%s"', $key, $value);
}, array_keys($options), $options);
return sprintf('<stjornvisi-rich %s><textarea %s>%s</textarea></stjornvisi-rich>', implode(' ', $strings), $this->createAttributesString($attributes), $escapeHtml($content));
}
示例3: reset
/**
* @param ElementInterface $element
*/
protected function reset(ElementInterface $element)
{
if ($element instanceof FieldsetInterface) {
foreach ($element as $elementOrFieldset) {
if ($elementOrFieldset instanceof FieldsetInterface) {
$this->reset($elementOrFieldset);
} else {
if ($elementOrFieldset->getOption(FormRow::RENDERED)) {
$elementOrFieldset->setOption(FormRow::RENDERED, null);
}
}
}
}
if ($element->getOption(FormRow::RENDERED)) {
$element->setOption(FormRow::RENDERED, null);
}
}