protected function createComponentForm($name) { $form = new \Nette\Application\UI\Form($this, $name); $form->setTranslator($this->getTranslator()); $form->setMethod($form::GET); $buttons = $form->addContainer(self::BUTTONS); $buttons->addSubmit('search', 'Grido.Search')->onClick[] = [$this, 'handleFilter']; $buttons->addSubmit('reset', 'Grido.Reset')->onClick[] = [$this, 'handleReset']; $buttons->addSubmit('perPage', 'Grido.ItemsPerPage')->onClick[] = [$this, 'handlePerPage']; $form->addSelect('count', 'Count', $this->getItemsForCountSelect())->setTranslator(NULL)->controlPrototype->attrs['title'] = $this->getTranslator()->translate('Grido.ItemsPerPage'); }
/** * Create filter form * @return \Nette\Application\UI\Form */ protected function createComponentFilterForm() { $form = new \Nette\Application\UI\Form(); $form->setMethod(\Nette\Application\UI\Form::GET); foreach ($this->getColumns() as $column) { $name = $column->getColumn(); $label = $column->labelPrototype->getText(); if ($column instanceof Columns\OptionColumn && $column->options) { $form->addSelect($name, $label, $column->getOptions())->setPrompt($label); } else { $form->addText($name, $label); } $form[$name]->getControlPrototype()->placeholder = $label; } $form->setDefaults($this->filter); $form->addSubmit('filter', 'Filter'); $form->addSubmit('reset', 'Reset')->onClick[] = $this->resetFilters; $form->onSuccess[] = $this->filterFormSubmitted; return $form; }