如何使用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 (编辑:北几岛)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|