编程语言
首页 > 编程语言> > php – Yii Framework:表单构建器

php – Yii Framework:表单构建器

作者:互联网

如何使用Yii中的表单构建器创建表单?它的数据模型是什么?

解决方法:

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?

这是Yii Form Builder页面的一个例子.

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));
}

该模型在函数的第一行中定义.

以下是Yii文档中的更多模型信息:Creating Model

标签:php,yii,formbuilder
来源: https://codeday.me/bug/20190630/1339950.html