示例#1
0
 public function testHandleRequest()
 {
     $checkbox = new Checkbox();
     $checkbox->setName('test');
     $checkbox->handle(new FormData('post', ['test' => 1]));
     $this->assertTrue($checkbox->isChecked());
     $checkbox->handle(new FormData('post', []));
     $this->assertFalse($checkbox->isChecked());
 }
示例#2
0
文件: Form.php 项目: sevikerr/form
 /**
  * ```
  * $form->checkbox('subscribe', 'Підписка на новини');
  * ```
  * @param string $name
  * @param string|null $label
  * @return Checkbox
  */
 public function checkbox($name, $label = null)
 {
     $checkbox = new Checkbox();
     $checkbox->setName($name);
     $checkbox->setLabel($label);
     $this->addElement($checkbox);
     return $checkbox;
 }