Yii Framework: Form Builder

How do you create a form using the form builder in Yii? What will be his data model?

+4
source share
1 answer

How to create a form builder in yii structure?

Using Form Builder

The Yii form designer uses the CForm object to present the specifications needed to describe the HTML form, including those data models that are associated with the form, which input fields are on the form, and how to display the entire form. Developers generally need to create and configure this CForm object, and then call its rendering method to display the form.


What will be his data model?

Here is an example from the YY Form Builder page.

public function actionLogin() { $model = new LoginForm; $form = new CForm('application.views.site.loginForm', $model); if($form->submitted('login') && $form->validate()) $this->redirect(array('site/index')); else $this->render('login', array('form'=>$form)); } 

The model is defined in the first line of the function.

Here is more information about the model from the Yii documentation: Creating a Model

+3
source

Source: https://habr.com/ru/post/1341985/


All Articles