M
M
Michael2020-08-03 23:19:06
Yii
Michael, 2020-08-03 23:19:06

How to make a form without using ActiveForm?

Hello everyone! There was such a question, is it possible to somehow create a contact form on the site without using ActiveForm.

<?php $form = ActiveForm::begin(); ?>
    <?= $form->field($model, 'name')->textInput(['placeholder' => 'Ваше имя']); ?>
    <?= $form->field($model, 'phone')->textInput(['placeholder' => 'Ваш телефон']); ?>
<?php ActiveForm::end(); ?>

How to use such a form, how to write an action to the controller that will be responsible for sending a letter, how to receive data from the form?
<form action=" method="post">                        
    <input type="text" name="name" placeholder="Ваше имя*">
    <input type="text" name="phone" placeholder="Ваш телефон*">
</form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-08-03
@Bally

<form action="<?= Url::to(['/site/contact']); ?>" method="post">                        
    <input type="text" name="name" placeholder="Ваше имя*">
    <input type="text" name="phone" placeholder="Ваш телефон*">
</form>

Get data from the formYii::$app->request->post();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question