php - yii2 ActiveForm field placeholder -
i want create form using yii2 activeform. here code:
<?php $form = \yii\widgets\activeform::begin([ 'options' => [ 'class' => 'form-inline' ] ]); ?> <div class="form-group"> <label class="sr-only" for="example">email</label> <?php echo $form->field($model, 'email', [ 'inputoptions' => ['autofocus' => 'autofocus', 'class' => 'form-control transparent'] ])->textinput(['placeholder' => "enter email"])->input('email')->label(false); ?> </div> <button type="submit" class="subscr-btn btn btn-primary btn-fill">join</button> <?php \yii\widgets\activeform::end(); ?> which generates html:
<form id="w0" class="form-inline" action="/example" method="post"> <div class="form-group"> <label class="sr-only" for="exampleinputemail2">email address</label> <div class="form-group field-subscriber-email required"> <input type="email" id="subscriber-email" class="form-control transparent" name="subscriber[email]" autofocus="autofocus"> <div class="help-block"></div> </div> </div> <button type="submit" class="subscr-btn btn btn-primary btn-fill">join</button> everything ok, placeholder?
put inside input() method second parameter - reference
<div class="form-group"> <label class="sr-only" for="example">email</label> <?php echo $form->field($model, 'email', [ 'inputoptions' => ['autofocus' => 'autofocus', 'class' => 'form-control transparent'] ])->textinput()->input('email', ['placeholder' => "enter email"])->label(false); ?> </div>
Comments
Post a Comment