A
A
Anton2016-07-18 15:51:19
Yii
Anton, 2016-07-18 15:51:19

Asterisks on required fields?

Good afternoon. How can I make sure that each required field has a red asterisk next to it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-07-18
Reytarovsky @Antonchik

for the second Yii in css add

form.marked .required .control-label:after,
form.marked label.mark-this:after{
  content: " *";
  color: #e9573f;
}

form.marked .required .no-mark-here .control-label:after{
  content: "" !important;
}

on the form, respectively, add the css-class marked

T
Toey, 2016-07-18
@Toey

to the model you are requesting

public function rules()
  {
  return array(
            array('email, password', 'required'),
        );
  }

email password fields will be with an asterisk
<div class="form">
    <?php $form=$this->beginWidget('CActiveForm', array(
        'id' => 'RegistrationForm_User',
        'enableClientValidation' => false,
    )); ?>

    <?php echo $form->errorSummary($model); ?>

    <div class="dr-col-50">
        <div class="row">
            <?php echo $form->labelEx($model, 'full_name'); ?>
            <?php echo $form->textField($model, 'full_name'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model, 'email'); ?>
            <?php echo $form->textField($model, 'email', ['placeholder' => 'E-mail']); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model, 'password'); ?>
            <?php echo $form->passwordField($model, 'password'); ?>
        </div>
    </div>
    <div class="clearfix"></div>
    <?php $this->endWidget(); ?>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question