Answer the question
In order to leave comments, you need to log in
How to display only "label" and "error" for a form (ActiveField) in Yii2?
Hello. Does anyone know how to display only "label" and "error" for a form (ActiveField) in Yii2?
I'm using the Redactor extension , with it you can only display the input field itself, but I also want to display the title for the field and the validation error.
The *yii\imperavi\Widget::widget* widget itself displays only the input field, without a title and errors. I hope everything is clear.
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->errorSummary($model); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => 255]) ?>
<?php echo yii\imperavi\Widget::widget(
[
'model' => $model,
'attribute' => 'text',
'options' => [],
]
);
?>
<br />
<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'),
['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']
) ?>
</div>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Yii1. What if you add it yourself?
<?= $form->labelEx($model, 'title') ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => 255]) ?>
<?= $form->error($model,'title') ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question