/** * (non-PHPdoc) * * @see \Simplify\Controller::indexAction() */ protected function indexAction() { try { $this->Form = new \Simplify\Form('options', __('Opções')); $this->Form->showMenu = false; $this->Form->addAction(new \Simplify\Form\Action\Config('config', __('Gerais'), \Simplify::config()->get('amp:tables:options'), 'option_name', 'option_value')); $this->Form->addElement(new \Simplify\Form\Element\Text('site_name', __('Nome do site')), \Simplify\Form::ACTION_CONFIG); $url = new \Simplify\Form\Element\Text('site_url', __('URL do site')); $this->Form->addElement($url, \Simplify\Form::ACTION_CONFIG); $this->Form->execute(); } catch (\Simplify\ValidationException $e) { \Simplify::session()->warnings(__('Ocorreram erros')); } $this->set('formBody', $this->Form->render()); }
/** * (non-PHPdoc) * * @see \Simplify\Controller::indexAction() */ protected function indexAction() { try { $this->Form->execute(); } catch (\Simplify\ValidationException $e) { \Simplify::session()->warnings(__('Ocorreram erros')); } $this->set('formBody', $this->Form->render()); }
/** * (non-PHPdoc) * @see \Simplify\Form::execute() */ public function execute($action = null) { $Action = $this->getAction($action); /** * * order * */ if ($Action->show(\Simplify\Form::ACTION_LIST)) { $Action->limit = false; $listAction = \Simplify::request()->get('listAction'); if ($listAction == self::LIST_ACTION_SORT) { $id = \Simplify::request()->get(\Simplify\Form::ID); $index = \Simplify::request()->get('index'); $this->repository()->moveTo($id, $index); } } return parent::execute($action); }
/** * (non-PHPdoc) * * @see \Simplify\Controller::indexAction() */ protected function indexAction() { try { $result = $this->Form->execute(); if ($result == \Simplify\Form::RESULT_SUCCESS) { \Simplify::session()->notices('Success'); return \Simplify::response()->redirect($this->Form->url()->extend()->set('formAction', null)); } } catch (\Simplify\ValidationException $e) { \Simplify::session()->warnings(__('Verifique os erros abaixo')); $errors = (array) $e->getErrors(); foreach ($errors as $key => $errors) { if (is_int($key)) { \Simplify::session()->warnings($errors); } } } catch (\Exception $e) { \Simplify::session()->warnings($e->getMessage()); } $this->set('formBody', $this->Form->render()); }
/** * (non-PHPdoc) * * @see \Simplify\Form::execute() */ public function execute($action = null) { $Action = $this->getAction($action); $label = $this->getLabel(); $pk = $this->getPrimaryKey(); $parent = $this->getParent(); $left = $this->getLeft(); $right = $this->getRight(); /** * order */ if ($Action->show(\Simplify\Form::ACTION_LIST)) { $listAction = \Simplify::request()->get('listAction'); if ($listAction == self::LIST_ACTION_SORT) { $id = \Simplify::request()->get(\Simplify\Form::ID); $index = \Simplify::request()->get('index'); $this->repository()->moveTo($id, $index); } } /** * filter by parent */ if ($Action->show(\Simplify\Form::ACTION_LIST)) { $q = $this->repository()->mptt()->query()->select(false)->select("node.{$pk}")->select("CONCAT(REPEAT('–', (COUNT(parent.{$pk}) - 1)), ' ', node.{$label}) AS {$label}")->select("(COUNT(parent.{$pk}) - 1) AS depth"); $data = $q->execute()->fetchAll(); $parents = array(0 => __('Nenhum')); $parents += sy_array_to_options($data, $pk, $label); $filter = new \Simplify\Form\Filter\Select($parent, __('Pai')); $filter->showEmpty = false; $filter->defaultValue = \Simplify::request()->get($parent, '0'); $filter->options = $parents; $this->addFilter($filter); } /** * edit parent */ if ($Action->show(\Simplify\Form::ACTION_EDIT || \Simplify\Form::ACTION_CREATE)) { $q = $this->repository()->mptt()->query()->select(false)->select("node.{$pk}")->select("CONCAT(REPEAT('–', (COUNT(parent.{$pk}) - 1)), ' ', node.{$label}) AS {$label}")->select("(COUNT(parent.{$pk}) - 1) AS depth"); $id = $this->getId(); if (!empty($id[0])) { $row = $this->repository()->find($id[0]); $q->where("node.{$left} NOT BETWEEN {$row[$left]} AND {$row[$right]}"); } $data = $q->execute()->fetchAll(); $parents = array(0 => __('Nenhum')); $parents += sy_array_to_options($data, $pk, $label); $parentSelect = new \Simplify\Form\Element\Select($parent, __('Pai')); $parentSelect->showEmpty = false; $parentSelect->defaultValue = \Simplify::request()->get($parent, '0'); $parentSelect->options = $parents; $this->addElement($parentSelect, \Simplify\Form::ACTION_EDIT | \Simplify\Form::ACTION_CREATE, 0); } return parent::execute($action); }