CakePHP 3 更改无线电输入模板
CakePHP 3 changing the radio input template
Cakephp 3 创建一个带标签的无线电容器 -> 像那样输入
<div class="radio">
<label class="radio-acces-checked" for="condition-access-1">
<input id="condition-access-1" type="radio" value="1" name="condition_access">
Free access
</label>
</div>
...
我想改变结构,但它不起作用,它总是相同的结构...你知道如何解决我的问题吗?
$myTemplates = [
'radioWrapper' => '<div class="radio">{{label}}{{input}}</div>'
];
echo $this->Form->radio('condition_access', [
['value' => 1, 'text' => __('Free Access')],
['value' => 2, 'text' => __('Payment Access')],
['value' => 3, 'text' => __('Reduce price')]
]);
您需要设置nestingLabel
模板:
echo $this->Form->input('condition_access', [
'type' => 'radio',
'options' => [
['value' => 1, 'text' => __('Free Access')],
['value' => 2, 'text' => __('Payment Access')],
['value' => 3, 'text' => __('Reduce price')]
],
'templates' => [
'nestingLabel' => '{{hidden}}<label{{attrs}}>{{text}}</label>{{input}}',
'radioWrapper' => '<div class="radio">{{label}}</div>'
]
]);
输出:
<div class="input radio">
<label>Condition Access</label>
<input name="condition_access" value="" type="hidden">
<div class="radio">
<label for="condition-access-1">Free Access</label>
<input name="condition_access" value="1" id="condition-access-1" type="radio">
</div>
<div class="radio">
<label for="condition-access-2">Payment Access</label>
<input name="condition_access" value="2" id="condition-access-2" type="radio">
</div>
<div class="radio">
<label for="condition-access-3">Reduce price</label>
<input name="condition_access" value="3" id="condition-access-3" type="radio">
</div>
</div>
Cakephp 3 创建一个带标签的无线电容器 -> 像那样输入
<div class="radio">
<label class="radio-acces-checked" for="condition-access-1">
<input id="condition-access-1" type="radio" value="1" name="condition_access">
Free access
</label>
</div>
...
我想改变结构,但它不起作用,它总是相同的结构...你知道如何解决我的问题吗?
$myTemplates = [
'radioWrapper' => '<div class="radio">{{label}}{{input}}</div>'
];
echo $this->Form->radio('condition_access', [
['value' => 1, 'text' => __('Free Access')],
['value' => 2, 'text' => __('Payment Access')],
['value' => 3, 'text' => __('Reduce price')]
]);
您需要设置nestingLabel
模板:
echo $this->Form->input('condition_access', [
'type' => 'radio',
'options' => [
['value' => 1, 'text' => __('Free Access')],
['value' => 2, 'text' => __('Payment Access')],
['value' => 3, 'text' => __('Reduce price')]
],
'templates' => [
'nestingLabel' => '{{hidden}}<label{{attrs}}>{{text}}</label>{{input}}',
'radioWrapper' => '<div class="radio">{{label}}</div>'
]
]);
输出:
<div class="input radio">
<label>Condition Access</label>
<input name="condition_access" value="" type="hidden">
<div class="radio">
<label for="condition-access-1">Free Access</label>
<input name="condition_access" value="1" id="condition-access-1" type="radio">
</div>
<div class="radio">
<label for="condition-access-2">Payment Access</label>
<input name="condition_access" value="2" id="condition-access-2" type="radio">
</div>
<div class="radio">
<label for="condition-access-3">Reduce price</label>
<input name="condition_access" value="3" id="condition-access-3" type="radio">
</div>
</div>