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()); }
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"234 ' 44"', $input->render()); }
/** * @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; }
/** * @return string */ public function render() { return '<label>' . parent::render() . $this->label . '</label>'; }