Beispiel #1
0
 /**
  * @param  array|\Traversable $data
  * @param  \TwiGrid\Record $record
  * @param  \Closure $primaryToString
  * @param  \Closure $containerFactory
  * @param  string|NULL $iePrimary
  * @return Form
  */
 public function addInlineEditControls($data, \TwiGrid\Record $record, \Closure $containerFactory, $iePrimary)
 {
     if (!$this->lazyCreateContainer('inline', 'buttons', $buttons)) {
         foreach ($data as $r) {
             if ($record->is($r, $iePrimary)) {
                 $this['inline']['values'] = $containerFactory($r);
                 $buttons->addSubmit('edit', 'Edit')->setValidationScope(array($this['inline']['values']));
                 $buttons->addSubmit('cancel', 'Cancel')->setValidationScope(array());
             } else {
                 $buttons->addComponent($ab = new PrimarySubmitButton('Edit inline'), $record->primaryToString($r));
                 $ab->setPrimary($record->primaryToString($r))->setValidationScope(array());
             }
         }
     }
     return $this;
 }
Beispiel #2
0
 /**
  * @param  array|\Traversable $data
  * @param  Record $record
  * @param  callable $containerFactory
  * @param  string|NULL $iePrimary
  * @return Form
  */
 public function addInlineEditControls($data, Record $record, callable $containerFactory, $iePrimary)
 {
     if ($this->lazyCreateContainer('inline', 'buttons', $buttons)) {
         foreach ($data as $rec) {
             if ($record->is($rec, $iePrimary)) {
                 $this['inline']['values'] = $containerFactory($rec);
                 $buttons->addSubmit('edit', 'Edit')->setValidationScope([$this['inline']['values']]);
                 $buttons->addSubmit('cancel', 'Cancel')->setValidationScope([]);
             } else {
                 $submit = new SubmitButton('Edit inline');
                 $submit->setValidationScope([]);
                 $buttons[$record->primaryToString($rec)] = $submit;
             }
         }
     }
     return $this;
 }