Skip to content

Commit

Permalink
Use 'val' like other inputs.
Browse files Browse the repository at this point in the history
Use the standard val option and add doc blocks.
  • Loading branch information
markstory committed Jan 14, 2014
1 parent b343357 commit 283a5b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/View/Input/Text.php
Expand Up @@ -15,7 +15,11 @@
namespace Cake\View\Input;

/**
* Text input class.
* Basic input class.
*
* This input class can be used to render basic simple
* input elements like hidden, text, email, tel and other
* types.
*/
class Text {

Expand All @@ -38,16 +42,27 @@ public function __construct($templates) {
/**
* Render a text widget or other simple widget like email/tel/number.
*
* This method accepts a number of keys:
*
* - `name` The name attribute.
* - `val` The value attribute.
* - `escape` Set to false to disable escaping on all attributes.
*
* Any other keys provided in $data will be converted into HTML attributes.
*
* @param array $data The data to build an input with.
* @return string
*/
public function render($data) {
$data += [
'name' => '',
'value' => null,
'val' => null,
'type' => 'text',
'escape' => true,
];
$data['value'] = $data['val'];
unset($data['val']);

return $this->_templates->format('input', [
'name' => $data['name'],
'type' => $data['type'],
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Input/TextTest.php
Expand Up @@ -74,7 +74,7 @@ public function testRenderWithValue() {
$data = [
'name' => 'my_input',
'type' => 'email',
'value' => 'Some <value>'
'val' => 'Some <value>'
];
$result = $text->render($data);
$expected = [
Expand Down

0 comments on commit 283a5b5

Please sign in to comment.