How to add textarea in yii2

Published on Author Code Father

You can use Active Forms to create fields like textarea for example

<?php $form = ActiveForm::begin(['id' => 'downloadSourceCode']); ?>
<?= $form->field($model, 'description')->textArea(['rows' => '6']) ?>
<?= Html::submitButton('Submit') ?>
<?php ActiveForm::end(); ?>

In the previouse example you are creating a form with a textarea inside, you can give it a name and pass the model from the controller to show the existing content of the model if you are editing it, if you are creating a new model, you will need to create a new object and then pass it to the view.

Comments

comments

Categories Yii