public function testElementRendering() { $input = new Input(); $input->setType('text'); $input->setValue('value'); $this->assertContains('<input type="text" value="value" ', $input->render()); }
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>'; }