M
M
mrCloud2014-04-01 01:00:35
Yii
mrCloud, 2014-04-01 01:00:35

How to replace field labels in YII?

Hello! Can you please tell me how to replace the usual labels with something similar to a placeholder from HTML?

<div class="row">
    <?php echo $form->labelEx($model,'username',array("label"=>"Пароль")); ?>
    <?php echo $form->textField($model,'username'); ?>
    <?php echo $form->error($model,'username'); ?>
  </div>

Tell me please:)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mrCloud, 2014-04-01
@mrCloud

I solved the issue with the following array, because For some reason, the placeholder did not want to work separately.

<?php echo $form->textField($model,'username',array('size'=>60,'maxlength'=>255,'encode'=>false,'value'=>'','placeholder'=>'Placeholder content')); ?>

S
Sergey, 2014-04-01
Protko @Fesor

don't call the labelEx method, and give textField an array of parameters as the third argument, one of which will be the placeholder:

<?php echo $form->textField($model,'username', ['placeholder' => 'password']); ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question