public function html($html = null) { if ($html !== null) { return parent::html($html); } $addBtn = '<div class="button-separator"><button type="button" class="format-child-add button">Add</button></div>'; $toolbar = sprintf('<div class="button-toolbar"><div>%s</div></div>', $this->getToolbarButtons()); $html = '<script type="js-template">' . $this->getTemplate()->toHtml("{$addBtn} {$toolbar}") . '</script>'; foreach ($this as $child) { $html .= $child->toHtml("{$addBtn} {$toolbar}"); } $html .= "<div>{$addBtn}</div>"; return $html; }
/** * {@inheritDoc} */ public function val($value = null) { if ($value === null) { return parent::val(); } $this->children = []; if ($value) { foreach ($value as $key => $value) { $child = isset($this->children[$key]) ? $this->children[$key] : $this->createDuplicate($key); $child->val($value); } } return $this; }