/** * {@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); }
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)); }
/** * @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); } }