我試圖像這樣<?php echo $form->label('full_name', 'Full name', array('wrap'=>'span','class' => 'required'));?>
cakephp:如何爲標籤添加span class?
預期輸出:
<label for="full_name"> Full name <span class="required"> </span> </label>
我試圖像這樣<?php echo $form->label('full_name', 'Full name', array('wrap'=>'span','class' => 'required'));?>
cakephp:如何爲標籤添加span class?
預期輸出:
<label for="full_name"> Full name <span class="required"> </span> </label>
<?php echo $form->label('full_name', 'Full name <span class="required"> </span>', array());?>
不知道是否有包裝標籤中的文本中的元素的蛋糕的方式。但上述將給你預期的結果。
你甚至可以把它簡化多一點,將其置於您輸入的元素:
<?php echo $this->Form->input('full_name', array('label'=>'<span>Full Name</span>', 'class'=>'required')); ?>
,你可以這樣做:
<?php
echo $this->Form->label('short_link', 'Custom URL <span style="font-size:9px;"><em>(Optional)</em></span>:', array('class' => 'YOUR CLASS FOR LABEL'));
echo $this->Form->input('short_link',array('label'=>false,'class'=>'YOUR CLASS FOR INPUT','value'=>'','size'=>'40'));
?>
感謝凱文... – user956965