/** * @param ElementInterface $element * @return string */ protected function getControl(ElementInterface $element) { $btnHelper = $this->getView()->plugin('btn'); $iconHelper = $this->getView()->plugin('icon'); if ($element instanceof Collection && $element->allowAdd() && $element->shouldCreateTemplate()) { return $btnHelper($iconHelper('plus'), ['class' => 'btn-success pull-right clearfix', 'onclick' => "return CmsCommon.Form.Collection.addFieldset(this, 'prepend');"]); } elseif ($element instanceof FieldsetInterface && !$element instanceof Collection && $element->getOption('allow_remove')) { return $btnHelper($iconHelper('minus'), ['class' => 'btn-danger pull-right clearfix', 'onclick' => 'return CmsCommon.Form.Collection.removeFieldset(this);']); } }
/** * Determines whether this element needs the add/remove buttons at all. * @param ElementInterface $element * @return boolean */ protected function needsButtons(ElementInterface $element) { if (!$element instanceof Collection) { return false; } return $element->allowAdd() || $element->allowRemove(); }
/** * @param ElementInterface $element * @return string */ protected function getControl(ElementInterface $element) { $control = ''; if ($element instanceof Collection && $element->allowAdd() && $element->shouldCreateTemplate()) { $control = ' <button type="button" class="btn btn-add-fieldset" ' . 'onclick="return CmsCommon.Form.Collection.addFieldset(this, \'prepend\');">' . '+</button>'; } elseif ($element instanceof FieldsetInterface && !$element instanceof Collection && $element->getOption('allow_remove')) { $control = ' <button type="button" class="btn btn-remove-fieldset" ' . 'onclick="return CmsCommon.Form.Collection.removeFieldset(this);">' . '-</button>'; } return $control; }