public function test_set_values_form() { $input3 = $this->mockInputText('name3'); $input2 = $this->mockInputText('name2'); $input1 = $this->mockInputText('name1'); $input3->expects($this->once())->method('setValue'); $form = new Form(); $form->addInput($input3); $aValues = array('name3' => 'value 3 du formulaire'); $form->setValues($aValues); $form_html = $form->getDisplay(); }
/** * URL: http://localhost:8080/?route=demo/four */ public function four() { $form = new Form(); $form->addField('firstname', 'WordField', array('blank' => false)); $form->addField('lastname', 'WordField', array('blank' => false)); $form->addField('telephone', 'NumericField'); $values = null; if ($this->request->isMethodPost()) { $form->setValues($_POST); if ($form->isValid()) { $values = $form->getValues(); } } $context = array('title' => 'four', 'form' => $form, 'values' => $values); $this->render('four.tpl', $context); }