Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use 'val' like other inputs.

Use the standard val option and add doc blocks.
  • Loading branch information...
commit 283a5b5b415d21168b132fe70599cbda2fce906a 1 parent b343357
@markstory markstory authored
Showing with 18 additions and 3 deletions.
  1. +17 −2 src/View/Input/Text.php
  2. +1 −1  tests/TestCase/View/Input/TextTest.php
View
19 src/View/Input/Text.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'],
View
2  tests/TestCase/View/Input/TextTest.php
@@ -74,7 +74,7 @@ public function testRenderWithValue() {
$data = [
'name' => 'my_input',
'type' => 'email',
- 'value' => 'Some <value>'
+ 'val' => 'Some <value>'
];
$result = $text->render($data);
$expected = [
Please sign in to comment.
Something went wrong with that request. Please try again.