|
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\Helper; |
|
17
|
|
|
|
|
18
|
|
|
use Core\View\Helper\FormHelper as CoreFormHelper; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class FormHelper |
|
22
|
|
|
* |
|
23
|
|
|
* @package Backend\View\Helper |
|
24
|
|
|
*/ |
|
25
|
|
|
class FormHelper extends CoreFormHelper |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* List of helpers used by this helper. |
|
30
|
|
|
* |
|
31
|
|
|
* @var array |
|
32
|
|
|
*/ |
|
33
|
|
|
public $helpers = [ |
|
34
|
|
|
'Url' => ['className' => 'Core.Url'], |
|
35
|
|
|
'Html' => ['className' => 'Backend.Html'], |
|
36
|
|
|
]; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Form switcher. |
|
40
|
|
|
* |
|
41
|
|
|
* @param string $fieldName |
|
42
|
|
|
* @param array $options |
|
43
|
|
|
* @return string |
|
44
|
|
|
*/ |
|
45
|
|
|
public function switcher($fieldName, array $options = []) |
|
46
|
|
|
{ |
|
47
|
|
|
$input = parent::checkbox($fieldName, $options); |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
$options += [ |
|
50
|
|
|
'before' => __d('backend', 'Off'), |
|
51
|
|
|
'after' => __d('backend', 'On') |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
|
|
$title = (isset($options['title'])) ? $options['title'] : $fieldName; |
|
55
|
|
|
|
|
56
|
|
|
if (!empty($title)) { |
|
57
|
|
|
$title = $this->Html->div('switch-title', $title); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$content = $this->formatTemplate(__FUNCTION__, [ |
|
61
|
|
|
'input' => $input, |
|
62
|
|
|
'lever' => '<span class="lever"></span>', |
|
63
|
|
|
'before' => $options['before'], |
|
64
|
|
|
'after' => $options['after'], |
|
65
|
|
|
'title' => $title, |
|
66
|
|
|
]); |
|
67
|
|
|
|
|
68
|
|
|
return $content; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.