Reputation: 1035
I using form field and set label like this :
<?= $form->field($unit, 'estimated_time')->textInput(['style' => 'width: 50px'])->label("Minutes") ?>
but label display in the left side of input-field How can I display it in right side ?
Upvotes: 2
Views: 8193
Reputation: 261
I think better solution is
<?= $form->field($unit, 'estimated_time', [
'template' => '{input}{label}{error}{hint}',
'options' => ['class' => 'form-group form-inline'],]
->textInput([
'style' => 'width: 50px; margin-right: 10px;']); ?>
Upvotes: 6
Reputation: 920
Assign style for your input like below:
<?= $form->field($unit, 'estimated_time', [
'template' => '<div style="float:right;">{label}</div>{input}{error}{hint}'
]);?>
more reference http://www.yiiframework.com/doc-2.0/yii-bootstrap-activefield.html
Upvotes: 0
Reputation: 250
Try this :
<?= $form->field($unit, 'estimated_time')->textInput(['style' => 'width: 50px'])->label('Your Label',['class'=>'label-class']) ?>
Add css as
.label-class{
float: right;
}
Upvotes: 0