Answer the question
In order to leave comments, you need to log in
How to place fields in a yii2 form that do not need to be sent, but need to be validated?
There is a form:
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'car')->textInput() ?>
<?= $form->field((new \frontend\models\SignupForm(), 'phone')->textInput() ?>
<?= Html::submitButton( 'Сохранить') ?>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
A strange decision, I'm sure that your problem is not solved by interception and similar pandemoniums, but if it's on the topic, then display the field outside the form, who forbids it?
You can also try this <input type="<тип>" form="<идентификатор>">
PS What does the php and yii tags have to do with it? They don't belong at all. HTML and more.
Better in such cases, write the problem you are trying to solve. After several readings, I agree with the previous message - why are such pandemoniums made.
In addition, as I understand you have your ajax requests. Use the framework tools - pass the parameter to the form enableAjaxValidation' => true and set the validation parameters in the rules() method.
<?php $form = ActiveForm::begin(['id'=>'registration-form',
'enableAjaxValidation' => true]); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question