示例#1
0
 public function testHandleRequest()
 {
     $input = new Input();
     $input->setName('email');
     $input->handle(new FormData(FormData::METHOD_POST, ['email' => '*****@*****.**']));
     $this->assertEquals('*****@*****.**', $input->getValue());
     $input->handle(new FormData(FormData::METHOD_POST, []));
     $this->assertNull($input->getValue());
 }
示例#2
0
 public function testValueWithSlashes()
 {
     $input = new Input();
     $input->setName('test');
     $input->setType('hidden');
     $value = ' 123"234 \' 44 ';
     $input->addFilter(new CallbackFilter('trim'));
     $input->setValue($value);
     $this->assertContains('<input type="hidden" name="test" value="123&quot;234 &#039; 44"', $input->render());
 }
示例#3
0
文件: Form.php 项目: sevikerr/form
 /**
  * @return string
  */
 public function renderStart()
 {
     $hidden = new Element\Input();
     $hidden->setType('hidden');
     $hidden->addAttributes(['name' => $this->getUid()]);
     $hidden->setValue(1);
     # get default attribute
     $method = $this->getMethod();
     $this->setAttribute('method', $method);
     $html = '<form ' . Element\Html::renderAttributes($this->getAttributes()) . '>';
     $html .= $hidden->render();
     # render hidden element
     foreach ($this->getElements() as $element) {
         if ($element instanceof Element\Input and $element->getType() === 'hidden') {
             $html .= $element->render();
         }
     }
     return $html;
 }
示例#4
0
 /**
  * @return string
  */
 public function render()
 {
     return '<label>' . parent::render() . $this->label . '</label>';
 }