public function text($name) { $text = new Text($name); if (!is_null($value = $this->getValueFor($name))) { $text->value($value); } return $text; }
public function text($name, $defaultValue = null) { $text = new Text($name); if (!is_null($value = $this->getValueFor($name))) { $text->value($value); } $text->defaultValue($defaultValue); if ($this->hasError($name)) { $text->setError(); } return $text; }
public function render() { $html = '<div class="input-group">'; $html .= $this->renderAddons($this->beforeAddon); $html .= parent::render(); $html .= $this->renderAddons($this->afterAddon); $html .= '</div>'; return $html; }
public function testDataAttribute() { $text = new Text('email'); $expected = '<input type="text" name="email" data-sample="test-value">'; $result = $text->data('sample', 'test-value')->render(); $this->assertEquals($expected, $result); $text = new Text('email'); $expected = '<input type="text" name="email" data-custom="another-value">'; $result = $text->data('custom', 'another-value')->render(); $this->assertEquals($expected, $result); }