From c0b92575118607007447ed064e1b81c9bc5e4311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Mon, 26 Apr 2010 20:57:27 +0200 Subject: [PATCH] Construct and display the AddPoints view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * define input form (draft) * create the view and make it display the form * add a link to the view in the topNav Signed-off-by: Michael Tänzer --- .../controllers/AddPointsController.php | 40 +++++++++++++- .../views/scripts/add-points/index.phtml | 14 +++++ manager/library/actions/ActionAddPoints.php | 53 +++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 manager/application/views/scripts/add-points/index.phtml create mode 100644 manager/library/actions/ActionAddPoints.php diff --git a/manager/application/controllers/AddPointsController.php b/manager/application/controllers/AddPointsController.php index 89ade78..ff66f0b 100644 --- a/manager/application/controllers/AddPointsController.php +++ b/manager/application/controllers/AddPointsController.php @@ -12,6 +12,44 @@ class AddPointsController extends Zend_Controller_Action public function indexAction() { - /* TODO */ + $this->view->assurance_form = $this->getAssuranceForm(); + $this->render('index'); + } + + public function assuranceAction() + { + /* Validate form */ + if (!$this->getRequest()->isPost()) { + return $this->_forward('index'); + } + + $form = $this->getAssuranceForm(); + if (!$form->isValid($_POST)) { + $this->view->assurance_form = $form; + return $this->render('index'); + } + + + /* Form is valid -> get values and process them */ + $values = $form->getValues(); + } + + protected function getAssuranceForm() + { + $form = new Zend_Form(); + $form->setAction('/add-points/assurance')->setMethod('post'); + + $quantity = new Zend_Form_Element_Text('quantity'); + $quantity->setRequired(true) + ->setLabel(I18n::_('Number of Points')) + ->addFilter(new Zend_Filter_Int()) + ->addValidator(new Zend_Validate_Between(0, 100)); + $form->addElement($quantity); + + $submit = new Zend_Form_Element_Submit('submit'); + $submit->setLabel(I18n::_('Assure Me')); + $form->addElement($submit); + + return $form; } } diff --git a/manager/application/views/scripts/add-points/index.phtml b/manager/application/views/scripts/add-points/index.phtml new file mode 100644 index 0000000..b627b78 --- /dev/null +++ b/manager/application/views/scripts/add-points/index.phtml @@ -0,0 +1,14 @@ + + +

+ +

+

+

+assurance_form ?> diff --git a/manager/library/actions/ActionAddPoints.php b/manager/library/actions/ActionAddPoints.php new file mode 100644 index 0000000..ef71b2f --- /dev/null +++ b/manager/library/actions/ActionAddPoints.php @@ -0,0 +1,53 @@ +