From 426a13372ec774a1bd26517cd80ee5632335fec1 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 2 May 2018 16:29:18 -0300 Subject: [PATCH] add examples --- app/control/contato/CityForm.php | 21 +++++++++++++++ app/control/contato/ContatoForm.php | 28 ++++++++++++++++++++ app/control/contato/ContatoList.php | 40 +++++++++++++++++++++++++++++ app/model/contato/City.php | 29 +++++++++++++++++++++ app/model/contato/Contato.php | 39 ++++++++++++++++++++++++++++ menu.xml | 10 +++++--- 6 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 app/control/contato/CityForm.php create mode 100644 app/control/contato/ContatoForm.php create mode 100644 app/control/contato/ContatoList.php create mode 100644 app/model/contato/City.php create mode 100644 app/model/contato/Contato.php diff --git a/app/control/contato/CityForm.php b/app/control/contato/CityForm.php new file mode 100644 index 0000000..c0b6440 --- /dev/null +++ b/app/control/contato/CityForm.php @@ -0,0 +1,21 @@ +panel->addCustomActionLink([ContatoList::class], 'fa:bars', 'Listagem'); + } +} diff --git a/app/control/contato/ContatoList.php b/app/control/contato/ContatoList.php new file mode 100644 index 0000000..3a28546 --- /dev/null +++ b/app/control/contato/ContatoList.php @@ -0,0 +1,40 @@ +panel->addRow([new DGridColumn($name)]); + } + + protected function createDatagridColumns($showId = false) + { + $this->datagrid->useDeleteAction(self::class); + + parent::createDatagridColumns($showId); + + $this->datagrid->useEditAction(ContatoForm::class); + } +} diff --git a/app/model/contato/City.php b/app/model/contato/City.php new file mode 100644 index 0000000..92a365d --- /dev/null +++ b/app/model/contato/City.php @@ -0,0 +1,29 @@ +addVarchar('name', 150, true, 'nome'); + } + + protected function buildStructureForm() + { + parent::setStructureForm([[$this->field_name]]); + } +} diff --git a/app/model/contato/Contato.php b/app/model/contato/Contato.php new file mode 100644 index 0000000..8aff722 --- /dev/null +++ b/app/model/contato/Contato.php @@ -0,0 +1,39 @@ +addVarchar('name', 150, true, 'nome'); + $this->addVarchar('cpf', 14)->mask('999.999.999-99'); + $this->addVarchar('rg', 12); + $this->addDate('birthday', 'data de nascimento'); + $this->addText('observation', 0, 80, false, 'observações'); + $this->addCombo('city_id', 'cidade')->model(City::class); + } + + protected function buildStructureForm() + { + $form_structure = [ + [$this->field_name], + [$this->field_cpf, $this->field_rg, $this->field_birthday, $this->field_city_id], + [$this->field_observation] + ]; + parent::setStructureForm($form_structure); + } +} diff --git a/menu.xml b/menu.xml index 6a3ed58..67c6b18 100755 --- a/menu.xml +++ b/menu.xml @@ -112,11 +112,15 @@ - + fa:bars fa-fw - - HumanForm + + ContatoForm + fa:bars fa-fw + + + CityForm fa:bars fa-fw