|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* CakeCMS Backend |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the of the simple cms based on CakePHP 3. |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* @package Backend |
|
10
|
|
|
* @license MIT |
|
11
|
|
|
* @copyright MIT License http://www.opensource.org/licenses/mit-license.php |
|
12
|
|
|
* @link https://github.com/CakeCMS/Backend". |
|
13
|
|
|
* @author Sergey Kalistratov <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Backend\View\Widget; |
|
17
|
|
|
|
|
18
|
|
|
use JBZoo\Utils\Str; |
|
19
|
|
|
use Cake\View\Form\ContextInterface; |
|
20
|
|
|
use Cake\View\Widget\TextareaWidget as CakeTextareaWidget; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class TextareaWidget |
|
24
|
|
|
* |
|
25
|
|
|
* @package Backend\View\Widget |
|
26
|
|
|
*/ |
|
27
|
|
|
class TextareaWidget extends CakeTextareaWidget |
|
28
|
|
|
{ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Render a text area form widget. |
|
32
|
|
|
* |
|
33
|
|
|
* Data supports the following keys: |
|
34
|
|
|
* |
|
35
|
|
|
* - `name` - Set the input name. |
|
36
|
|
|
* - `val` - A string of the option to mark as selected. |
|
37
|
|
|
* - `escape` - Set to false to disable HTML escaping. |
|
38
|
|
|
* |
|
39
|
|
|
* All other keys will be converted into HTML attributes. |
|
40
|
|
|
* |
|
41
|
|
|
* @param array $data The data to build a textarea with. |
|
42
|
|
|
* @param \Cake\View\Form\ContextInterface $context The current form context. |
|
43
|
|
|
* @return string HTML elements. |
|
44
|
|
|
*/ |
|
45
|
|
|
public function render(array $data, ContextInterface $context) |
|
46
|
|
|
{ |
|
47
|
|
|
$data = array_merge(['class' => null], $data); |
|
48
|
|
|
|
|
49
|
|
|
$data['class'] .= ' materialize-textarea'; |
|
50
|
|
|
$data['class'] = Str::trim($data['class']); |
|
51
|
|
|
|
|
52
|
|
|
return parent::render($data, $context); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|