user956965
user956965

Reputation: 1

cakephp: How add span class for label in?

i was trying like this <?php echo $form->label('full_name', 'Full name', array('wrap'=>'span','class' => 'required'));?>

Expected output:

<label for="full_name"> Full name <span class="required">&nbsp;</span> </label>

Upvotes: 0

Views: 3731

Answers (3)

hoai pham thanh
hoai pham thanh

Reputation: 41

you can do like this :

        <?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'));
        ?>

Upvotes: 1

Tim Joyce
Tim Joyce

Reputation: 4517

you can even simplify it a bit more by putting it inside your input element :

<?php echo $this->Form->input('full_name', array('label'=>'<span>Full Name</span>', 'class'=>'required')); ?>

Upvotes: 0

Kevin Vandenborne
Kevin Vandenborne

Reputation: 1387

<?php echo $form->label('full_name', 'Full name <span class="required">&nbsp;</span>', array());?>

Not sure if there's a cake way of wrapping the text inside the label in an element. But the above will give you the expected result.

Upvotes: 1

Related Questions