public function render() { $this->tag->addAttribute('action', $this->arguments['action']); $hiddenFields = array(); /** @var FormField $hiddenField */ foreach ($this->arguments['form']->getHiddenFields() as $hiddenField) { $tag = new TagBuilder('input'); $tag->addAttributes(['type' => 'hidden', 'name' => $hiddenField->getName(), 'value' => $hiddenField->getValueOrDefault()]); $hiddenFields[] = $tag->render(); } $content = implode(chr(10), $hiddenFields) . chr(10) . $this->renderChildren(); $this->tag->setContent($content); $output = $this->tag->render(); return $output; }
/** * Sets the tag name to $this->tagName. * Additionally, sets all tag attributes which were registered in * $this->tagAttributes and additionalArguments. * * Will be invoked just before the render method. * * @return void * @api */ public function initialize() { parent::initialize(); $this->tag->reset(); $this->tag->setTagName($this->tagName); if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) { $this->tag->addAttributes($this->arguments['additionalAttributes']); } if ($this->hasArgument('data') && is_array($this->arguments['data'])) { foreach ($this->arguments['data'] as $dataAttributeKey => $dataAttributeValue) { $this->tag->addAttribute('data-' . $dataAttributeKey, $dataAttributeValue); } } if (isset(self::$tagAttributes[get_class($this)])) { foreach (self::$tagAttributes[get_class($this)] as $attributeName) { if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') { $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]); } } } }