Answer the question
In order to leave comments, you need to log in
Do I need to use dynamic model here?
If the form has a select field in it, when you select something from the select, ajax is performed and the view is rendered with some fields. But the fields that are rendered from this model are not validated, do these fields need to be done through the dynamic model or am I just doing something wrong?
Here is the additional view itself, which is rendered with ajax
<? $form = ActiveForm::begin()?>
<div class="row">
<?= $form->field($model,'size',['options' => ['class' => 'input-field col s12 m4'], 'template' =>
'{input}<label class="control-label" for="post-title">Size<span class="req"> *</span></label>{error}'])->textInput() ?>
</div>
<? $form = ActiveForm::end() ?>
class PostFormTest extends Model
{
public $name_agent;
public $email_agent;
public $phone_agent;
public $title;
public $id_category;
public $id_sub_category;
public $city;
public $price;
public $term_price_product;
public $term_time_post;
public $maps;
/*Rental for rent*/
public $size;
/*****************/
public function rules(){
return[
[['name_agent', 'email_agent', 'phone_agent', 'title', 'id_category', 'id_sub_category', 'city', 'price',
'term_price_product', 'term_time_post'], 'required'],
['email_agent', 'email'],
['phone_agent', 'match', 'pattern' => '/^\+\d+$/'],
['phone_agent', 'string', 'min' => 6],
['phone_agent', 'string', 'max' => 20],
['title', 'string', 'min' => 6, 'max' => 255],
['size', 'string', 'min' => 6, 'max' => 255],
['maps', 'safe'],
];
}
}
Answer the question
In order to leave comments, you need to log in
not validated
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question