Title we use modal PopOver +ajax Submit form First we add the Create button for the index view Data-toggle and Data-target.
The code is as follows:
<?phpecho html::a (' Add leave order ', [' Create '], [' class ' = ' btn ' btn-success ', ' data-toggle ' = ' modal ', ' data-target ' = > ' #ajax '])?>
In the index view, add the following code to display the Modal popup box:
<div class= "Modal Bs-example-modal-lg" id= "ajax" > <div class= "Modal-dialog" > <div class= " Modal-content width_reset "id=" Tmpl-modal-output-render "> </div> </div> </div>
The modified effect is as follows
Then we modify the Create method in the controller and change the render to Renderajax.
return $this->renderajax (' Create ', [' model ' = $model,]);
If you want to add a form validation we need to modify the _form in the views to add the ID
<?php $form = Activeform::begin ([' options '] = [' enctype ' = ' multipart/form-data '], ' id ' and ' = ' Leave-form-self '])?> point to your models on the rules Add Validation rule public function rules () { return [[ ' t_leave_date ', ' t_ Days ', ' T_reason ', ' t_nickname ', ' t_leave_enddate ', ' required '], [[' T_leave_date ', ' t_leave_enddate '], ' safe '], [[' T_days '], ' number '], [[' T_reason '], ' string '], [[' Type ', ' add_time ', ' uid ', ' update_time ', ' status ', ' Is_shen '], ' integer '], [[' T_ Pickup ', ' t_nickname ', ' t_pass '], ' string ', ' max ' = ', ' [ [' t_img ', ' reviewer_user ', ' audit_user '], ' string ', ' Max ' = 255] ; }
The effect is as follows
This enables the AJAX submission form