Esempio n. 1
0
 function testRender()
 {
     $e = new RadioListing('test');
     $e->setOptions('one', 'two');
     $e->setOptionsIgnoreKeys();
     $exp = '<label><input name="test" type="radio" value="one" /> one</label>' . "\n" . '<label><input name="test" type="radio" value="two" /> two</label>' . "\n";
     $act = $e->render();
     $this->assertEquals($exp, $act, 'Список радиобатонов по значениям');
     $e->setFilter('is_numeric');
     $e->validate('one');
     $this->assertSelectCount('input[checked=checked]', true, $e->render(), 'Один пункт выделен');
     $e = new RadioListing('test');
     $e->setOptions(array(1 => 'one', 2 => 'two'));
     $e->setSeparator('<br />');
     $exp = '<label><input name="test" type="radio" value="1" /> one</label><br />' . "\n" . '<label><input name="test" type="radio" value="2" /> two</label><br />' . "\n";
     $act = $e->render();
     $this->assertEquals($exp, $act, 'Список радиобатонов ключ-значение с разделителем');
     $e->validate(2);
     $this->assertSelectCount('input[checked=checked]', true, $e->render(), 'Один пункт выделен');
 }
Esempio n. 2
0
File: Form.php Progetto: cmsx/form
 /** @return Form\Element\RadioListing */
 public function addRadioListing($field, $label = null, $options = null)
 {
     $l = new RadioListing($field, $label, $this);
     if ($options) {
         $l->setOptions($options);
     }
     return $this->fields[$field] = $l;
 }