1: <?php
2: /**
3: * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4: * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5: *
6: * Licensed under The MIT License
7: * For full copyright and license information, please see the LICENSE.txt
8: * Redistributions of files must retain the above copyright notice.
9: *
10: * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11: * @link https://cakephp.org CakePHP(tm) Project
12: * @since 3.0.0
13: * @license https://opensource.org/licenses/mit-license.php MIT License
14: */
15: namespace Cake\View\Widget;
16:
17: use Cake\View\Form\ContextInterface;
18:
19: /**
20: * Input widget class for generating a textarea control.
21: *
22: * This class is intended as an internal implementation detail
23: * of Cake\View\Helper\FormHelper and is not intended for direct use.
24: */
25: class TextareaWidget extends BasicWidget
26: {
27: /**
28: * Render a text area form widget.
29: *
30: * Data supports the following keys:
31: *
32: * - `name` - Set the input name.
33: * - `val` - A string of the option to mark as selected.
34: * - `escape` - Set to false to disable HTML escaping.
35: *
36: * All other keys will be converted into HTML attributes.
37: *
38: * @param array $data The data to build a textarea with.
39: * @param \Cake\View\Form\ContextInterface $context The current form context.
40: * @return string HTML elements.
41: */
42: public function render(array $data, ContextInterface $context)
43: {
44: $data += [
45: 'val' => '',
46: 'name' => '',
47: 'escape' => true,
48: 'rows' => 5,
49: 'templateVars' => []
50: ];
51:
52: return $this->_templates->format('textarea', [
53: 'name' => $data['name'],
54: 'value' => $data['escape'] ? h($data['val']) : $data['val'],
55: 'templateVars' => $data['templateVars'],
56: 'attrs' => $this->_templates->formatAttributes(
57: $data,
58: ['name', 'val']
59: )
60: ]);
61: }
62: }
63: