Get the App
SLTechnology News&Howtos  ›  Development  › 

Example usage of Yii2.0 mode pop-up box and ajax submission form

Shulou Source: shulou.com Published: 2022-06-03 19:47:34 11月12日 Update

This article mainly explains the "Yii2.0 mode pop-up box and ajax submission form example usage", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "Yii2.0 mode pop-up box and ajax submission form example usage" bar!

For example, we use the modal pop-up box + ajax to submit the form. First we add the create button of the index view to data-toggle and data-target.

The code is as follows:

Add the following code to the index view to display the modal pop-up box:

The effect of the modification 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 we want to add form validation, we need to modify the _ form in views and add id

Point to your models to add verification rules public function rules () {return to rules ['tasking checking dates,' tasking dayscodes, 'tweeds reasoned,' tweeds nicknameworthy dagnamestaments'], 'required'], [[' tweeds dated dates, 'tweeds dated enddates'], 'safe'], [[' tasking days'], 'number'], [[' tasking reasoning]] 'string'], [[' type', 'add_time',' uid', 'update_time',' status', 'is_shen'],' integer'], [['tweeted pickling,' tweeted nickname passages'], 'string',' max' = > 20], [['tweeimg,' reviewer_user', 'audit_user'],' string', 'max' = > 255]] }

The effect is as follows

This enables the ajax to submit the form

Thank you for your reading, the above is the "Yii2.0 mode pop-up box and ajax submission form example usage" of the content, after the study of this article, I believe you on the Yii2.0 mode pop-up box and ajax submission form example usage of this problem has a deeper understanding, the specific use of the need for you to practice verification. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Forms modes examples learning verification code content effects views that is ideas situations points buttons controllers articles methods more knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Xiaomi MariaDB Docker Shulou Tech Info