Пример #1
0
 /**
  * Create the new field object.
  *
  * @return Field
  */
 public function createInstance()
 {
     $field = new Field();
     $field->setId($this->rowCollectionEditor->getId())->setLabel($this->rowCollectionEditor->getTitle())->setEditable(true)->setVisible(false)->assignHelperCallback('SaveHandler', function () {
         return $this->rowCollectionEditor;
     })->assignHelperCallback('EditControl.Control', function (EditControl $helper) {
         $helperName = $this->editViewHelperName;
         return $helper->getView()->{$helperName}($this->rowCollectionEditor, $this->editViewHelperOptions);
     })->assignHelperCallback('EditControl.Label', function () {
         return null;
     })->assignHelperCallback('InputFilter', function () {
         return $this->getInputFilterFactory()->createInstance();
     })->assignHelperCallback('TableCell.Content', function (TableCell $helper, array $rowData) {
         $helperName = $this->tableCellViewHelperName;
         return $helper->getView()->{$helperName}($this->rowCollectionEditor, array_merge(['rowData' => $rowData, 'mapping' => $this->tableCellMapping, 'renderer' => $helper], $this->tableCellViewHelperOptions));
     });
     return $field;
 }
Пример #2
0
 /**
  * Create the Input instance.
  *
  * We specify that validation should continue if the input is empty because
  * the RowCollectionEditor itself won't every receive a value.  It is just
  * iterating over its own editors and setting values/validating them each.
  *
  * @return Input
  */
 public function createInstance()
 {
     $input = new Input($this->rowCollectionEditor->getId());
     $input->setRequired(false)->setAllowEmpty(true)->setContinueIfEmpty(true)->getValidatorChain()->attach($this->createCallbackValidator());
     return $input;
 }