Yii Framework Forum: Autogenerated Form - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Autogenerated Form Generating a form from ActiveRecord Rate Topic: -----

#1 User is offline   jonotime 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-March 13

Posted 21 March 2013 - 09:09 PM

Hi All,

I have an ActiveRecord model which I would like to auto generate a form for.

I looked at CForm, but the constructor requires the first parameter explicitly state all the fields and their specifications.

Is there a way to not have to specify such things?

Can it infer from the ActiveRecord item what the field type is (ie - textarea, text, checkbox, etc)? Ideally this would also automatically figure out validation requirements (ie - null fields, and lengths).

Perhaps I am looking in the wont place for such a thing?

Basically I want something like this:

public function actionShowrow()
{
$model = Row::model();
$form = new FormFromModel($model);
if($form->submitted('login') && $form->validate())
$this->redirect(array('site/index'));
else
$this->render('login', array('form'=>$form));
}
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users