Update framework/web/helpers/CHtml.php #2012

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@viglu

Add some inner "prefix"/"suffix" html code around the label content, without modifying CHtml::$beforeRequiredLabel and CHtml::$afterRequiredLabel

Example source code of how to use

echo $form->labelEx($model,'email', array('class'=>'control-label', 'beforeInnerLabel'=>'<i class="icon-envelope"></i> '));
echo $form->labelEx($model,'subject', array('class'=>'control-label', 'beforeInnerLabel'=>'<i class="icon-question-sign"></i> '));

It this case we are adding an image before the label content "Email"

beforeInnerLabel and afterInnerLabel can also be used if a label don't have the "require" tag.

See produced html code demo page http://shop.glasbuttek.lu/information/contact

@viglu viglu Update framework/web/helpers/CHtml.php
Add some inner "prefix"/"suffix" html code around the label content, without modifying CHtml::$beforeRequiredLabel and CHtml::$afterRequiredLabel

Example source code of how to use
echo $form->labelEx($model,'email', array('class'=>'control-label', 'beforeInnerLabel'=>'<i class="icon-envelope"></i> '));
echo $form->labelEx($model,'subject', array('class'=>'control-label', 'beforeInnerLabel'=>'<i class="icon-question-sign"></i> '));

It this case we are adding an image <i class="icon-envelope"></i> before the label content "Email"

beforeInnerLabel and afterInnerLabel can also be used if a label don't have the "require" tag.

See produced html code demo page http://shop.glasbuttek.lu/information/contact
0659f89
@resurtm

Following code can be used without modifying CHtml:

<?php echo CHtml::activeLabelEx(
    $post,
    'category',
    array('label'=>'<strong>Text</strong> '.$post->getAttributeLabel('category'))
); ?>

Produces:

<label for="Post_category"><strong>Text</strong> Category</label>

In my opinion (and past experience) making such labels is rather unusual case, so i'm against merging that.

@samdark
Yii Software LLC member

It's not that unusual for CSS frameworks but I agree that workaround provided is equally OK. Closing this PR.

@samdark samdark closed this Mar 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment