开发者

Yii Framework:Form builder

How do you create a form using the form builder in Yii? What will be its data 开发者_StackOverflow中文版model?


How to make a form builder in yii framework?

Using Form Builder

The Yii form builder uses a CForm object to represent the specifications needed to describe an HTML form, including which data models are associated with the form, what kind of input fields there are in the form, and how to render the whole form. Developers mainly need to create and configure this CForm object, and then call its rendering method to display the form.


What will be its data model?

Here's an example from the Yii 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's more model information from the Yii documentation: Creating Model

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜