Answer the question
In order to leave comments, you need to log in
How to display a form in one controller, action and view, and send data to another?
Good evening, please tell me how to make a form in one controller and action, and send the data to another?
I have a "Book" model, a "BookController" controller and an "actionView" method that renders a "view" view and I need to make a form in it via an ActivForm.
Output 1 field ("animal_id") that belongs to the "Lead" model. And you need to pass the value that falls into "animal_id" to "actionCreate".
I do like this:
<?php $form = ActiveForm::begin([
'method' => 'get',
'action' => ['lead/create'],
]); ?>
<?= $form->field($model, 'animal_id',['options' => ['class' => 'col-xs-6']]);
?>
<?= Html::submitButton('Ок', ['class' => 'btn btn-success']) ?>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
If I understand correctly, you want to link two different models in one form, look here
But an error is thrown: Call to a member function isAttributeRequired() on null
$model
you it is casual not null
at a stage of an output of the form?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question