微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐