根据我的需要定制表格助手
<?php
namespace App\View\Helper;
use Cake\View\Helper;
class IecFormHelper extends Helper
{
public $helpers = ['Form'];
public $iecFormConfig = [
'templates' => [
'input' => '<input type="{{type}}" name="{{name}}"{{attrs}} onBlur=update_data(this.id) />',
]
];
public function date($fieldName, array $options = [])
{
$options += [
'empty' => true,
'value' => null,
'monthNames' => true,
'minYear' => 1950,
'maxYear' => date('Y') + 50,
'orderYear' => 'desc',
];
$options['hour'] = $options['minute'] = false;
$options['meridian'] = $options['second'] = false;
$options = $this->_initInputField($fieldName, $options);
$options = $this->_datetimeOptions($options);
return $this->widget('datetime', $options);
}
}
我在“ src / View / Helper”下有这个帮助程序类,该类基本上具有用于在模糊时调用javascript函数的模板规则,并且我还想更改所有日期下拉列表的minYear和maxYear值。
我的问题是如何以及在何处使用此帮助器,以便它覆盖主FormHelper中的规则。
您可以只加载它并使用您的Helper而不是form helper。
如果要覆盖Formhelper,则应在IecFormHelper中扩展FormHelper。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句