Esempio n. 1
0
 /**
  * Setup the row editor and check component permissions.
  */
 public function init()
 {
     $this->rowEditor = $this->getRowEditor();
     $this->model = $this->getModel();
     $this->fields = $this->getFields();
     // Ensure primary key field is instantiated so that it is linked by row editor
     $this->component->getFields()->add($this->component->getListing()->getPrimaryKey())->setEditable(false);
     $this->rowEditor->link();
     $this->isNew = $this->rowEditor->isNew();
     $this->checkPermissions();
 }
Esempio n. 2
0
 /**
  * Get the \Dewdrop\Fields\RowEditor object that will assist with the
  * editing of items in this component.
  *
  * @return RowEditor
  */
 public function getRowEditor()
 {
     if (!$this->rowEditor) {
         $fields = $this->getFields();
         $this->rowEditor = new RowEditor($fields, $this->getRequest());
         $this->rowEditor->linkByQueryString('users', 'user_id')->link();
         if ($this->rowEditor->isNew()) {
             $this->addPasswordFields($fields);
         }
     }
     return $this->rowEditor;
 }
 /**
  * Create a Field object for handling deletion of items.
  *
  * @param RowEditor $editor
  * @return Field
  */
 private function createDeleteField(RowEditor $editor)
 {
     $field = new Field();
     $field->setId('delete')->setEditable(true)->assignHelperCallback('InputFilter', function () {
         $input = new \Zend\InputFilter\Input('delete');
         $input->setAllowEmpty(true);
         return $input;
     })->assignHelperCallback('EditControl.Label', function () {
         return '<span class="glyphicon glyphicon-trash"></span>';
     })->assignHelperCallback('EditControl.Control', function () use($editor) {
         if ($editor->isNew()) {
             $out = '<button data-is-new="1" class="btn btn-danger btn-delete">';
         } elseif ($editor->hasDeleteField()) {
             $out = '<button data-is-new="0" class="btn btn-danger btn-delete">';
         } else {
             $out = '<button data-is-new="0" class="btn btn-danger btn-delete disabled">';
         }
         $out .= '<span class="glyphicon glyphicon-trash"></span>';
         $out .= '</button>';
         return $out;
     });
     return $field;
 }
Esempio n. 4
0
 /**
  * Pass dependencies into the View.
  */
 public function render()
 {
     $this->view->assign(['component' => $this->component, 'componentModel' => $this->component->getPrimaryModel(), 'fields' => $this->fields, 'rowEditor' => $this->rowEditor, 'breadcrumbTitle' => $this->rowEditor->isNew() ? 'Add' : 'Edit']);
     return $this->renderView();
 }
Esempio n. 5
0
 /**
  * @expectedException \Dewdrop\Exception
  */
 public function testCallingIsNewPriorToLinkingThrowsException()
 {
     $this->rowEditor->isNew();
 }