/** * @param Forms\Form $form * @return void */ public function processForm(Forms\Form $form) { // detect submit button by lazy buttons appending (beginning with the most lazy ones) $this->addFilterButtons(); if (($button = $form->submitted) === TRUE) { $this->addGroupActionButtons(); if (($button = $form->submitted) === TRUE) { $this->addPaginationControls(); if (($button = $form->submitted) === TRUE) { $this->addInlineEditControls(); $button = $form->submitted; } } } if ($button instanceof Nette\Forms\Controls\SubmitButton) { $name = $button->name; $path = $button->parent->lookupPath('TwiGrid\\Forms\\Form'); if ("{$path}-{$name}" === 'filters-buttons-filter') { $this->addFilterCriteria(); ($criteria = $form->getFilterCriteria()) !== NULL && $this->setFilters($criteria); } elseif ("{$path}-{$name}" === 'filters-buttons-reset') { $this->setFilters(array()); $this->defaultFilters !== NULL && ($this->polluted = TRUE); } elseif ("{$path}-{$name}" === 'pagination-buttons-change') { $this->handlePaginate($form->getPage()); } elseif ($path === 'actions-buttons') { if (($checked = $form->getCheckedRecords($this->getRecord()->primaryToString)) !== NULL) { $records = array(); foreach ($checked as $primaryString) { ($record = Helpers::findRecord($this->getData(), $primaryString, $this->getRecord())) !== NULL && ($records[] = $record); } NCallback::invoke($this['groupActions']->getComponent($name)->callback, $records); $this->refreshState(); $this->redraw(TRUE, TRUE, 'body', 'footer'); } } elseif ($path === 'inline-buttons') { if ($name === 'edit') { if (($values = $form->getInlineValues()) !== NULL) { NCallback::invoke($this->ieProcessCallback, Helpers::findRecord($this->getData(), $this->iePrimary, $this->getRecord()), $values); $this->deactivateInlineEditing(); } } elseif ($name === 'cancel') { $this->deactivateInlineEditing(FALSE); } else { $this->activateInlineEditing($button->primary); } } } }