Skip to content
Permalink
Browse files

Use 'val' like other inputs.

Use the standard val option and add doc blocks.
  • Loading branch information...
markstory committed Jan 14, 2014
1 parent b343357 commit 283a5b5b415d21168b132fe70599cbda2fce906a
Showing with 18 additions and 3 deletions.
  1. +17 −2 src/View/Input/Text.php
  2. +1 −1 tests/TestCase/View/Input/TextTest.php
@@ -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 {
@@ -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'],
@@ -74,7 +74,7 @@ public function testRenderWithValue() {
$data = [
'name' => 'my_input',
'type' => 'email',
'value' => 'Some <value>'
'val' => 'Some <value>'
];
$result = $text->render($data);
$expected = [

0 comments on commit 283a5b5

Please sign in to comment.
You can’t perform that action at this time.