Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created March 10, 2014 06:18
Show Gist options
  • Save umidjons/9460276 to your computer and use it in GitHub Desktop.
Save umidjons/9460276 to your computer and use it in GitHub Desktop.
Yii: Set custom text for label

#Set custom text for label

htmlOptions of such CHtml::activeLabel and CActiveForm::label methods have label special option. It specifies the label to be displayed instead of CModel::getAttributeLabel value.

<div class="form-group">
	<div class="col-sm-6">
		<?= $form->label( $model, 'source_title', [ 'label' => Yii::t( 'myApp', 'Resource title' ) ] ); ?>
		<?= $form->textField( $model, 'source_title', [ 'class' => 'form-control', ] ); ?>
		<?= $form->error( $model, 'source_title', [ 'class' => 'text-danger' ] ); ?>
	</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment