public function testEmptyFormNameShouldNotRenderEmptyFormId() { $form = new Form(); $form->setMethod('post')->setAction('/foo/bar')->setView($this->getView()); $html = $form->render(); $this->assertNotContains('id=""', $html, $html); }
/** * @group ZF-4038 */ public function testCaptchaShouldRenderFullyQualifiedElementName() { $form = new Form(); $form->addElement($this->element)->setElementsBelongTo('bar'); $html = $form->render(new View()); $this->assertContains('name="bar[foo', $html, $html); $this->assertContains('id="bar-foo-', $html, $html); $this->form = $form; }
/** * @group ZF-2828 */ public function testCanPopulateCheckboxOptionsFromPostedData() { $form = new Form(array('elements' => array('100_1' => array('MultiCheckbox', array('multiOptions' => array('100_1_1' => 'Agriculture', '100_1_2' => 'Automotive', '100_1_12' => 'Chemical', '100_1_13' => 'Communications'), 'required' => true))))); $data = array('100_1' => array('100_1_1', '100_1_2', '100_1_12', '100_1_13')); $form->populate($data); $html = $form->render($this->getView()); foreach ($form->getElement('100_1')->getMultiOptions() as $key => $value) { if (!preg_match('#(<input[^>]*' . $key . '[^>]*>)#', $html, $m)) { $this->fail('Missing input for a given multi option: ' . $html); } $this->assertContains('checked="checked"', $m[1]); } }
/** * @group ZF-2950 */ public function testSubFormGetsUniqueIdWithName() { $form = new Form(); $form->setView($this->getView())->setName('testform')->addSubForm(new \Zend\Form\SubForm(), 'testform'); $html = $form->render(); $this->assertContains('<dt id="testform-label"> </dt>', $html); $this->assertContains('<dd id="testform-element">', $html); }
/** * @group ZF-3272 */ public function testRenderedSubFormDtShouldContainNoBreakSpace() { $subForm = new SubForm(array('elements' => array('foo' => 'text', 'bar' => 'text'))); $form = new Form(); $form->addSubForm($subForm, 'foobar')->setView(new View()); $html = $form->render(); $this->assertContains('> </dt>', $html); }