Пример #1
0
 /**
  * @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);']);
     }
 }
Пример #2
0
 /**
  * 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();
 }
Пример #3
0
 /**
  * @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;
 }