Yii Framework Forum: CForm - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

CForm Rate Topic: -----

#41 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 26 June 2009 - 07:43 AM

Yes, I was definitely interested in your work. :) Well, I didn't say this is how it will be released. It was just a neat summary.

If I could have a suggestion, I'd recommend not to fully remove subviews. One may want to call $form->render('path/to/view'); so it'd easy to customize the output html.

My other idea is naming syntax. Currently, ids and names are fully auto-generated. What about naming rules, which can determine both?

A naming rule may look like form-{type}-{attribute}. In this case, {type} and {attribute} would replaced by the input field type (text, password, dropdown, etc.) and attribute name identified by form respectively. A rule also may be empty, which means the corresponding html attribute should be omitted.

How does this sound?
0

#42 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 26 June 2009 - 07:51 AM

Thank you for your comments.

For subviews, I think one can do $this->renderPartial('view', array('form'=>$form)) to explicitly render a form. This is nearly the same as $form->render('view'). The only difference is that in the view, $this would refer to controller/widget in the former case, while in the latter case it refers to the form object.

The current implementation allows you to customize id easily:

'username'=>array(
  'type'=>'text',
  'id'=>'username',
)

I'm not sure about name generation. It is required so that data population is smooth.
0

#43 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 26 June 2009 - 08:40 AM

Well put. Very true indeed. It is nice to know we can still use traditional ways instead of adding complexity.
0

#44 User is offline   sdietz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 04-July 09

Posted 04 July 2009 - 07:16 AM

I really like what I've seen of this Formframework so far.

Also started tinkering with it and porting some of my projects to put it to use.

I may have missed how the tabular input using subforms is used. Could somebody give me a heads up regarding this? (eg. a Game a 2-* Players)
0

#45 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 04 July 2009 - 07:20 AM

Currently CForm is not designed to work with tabular input yet... It can work with multiple models via subform, though.
0

#46 User is offline   sdietz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 04-July 09

Posted 04 July 2009 - 07:33 AM

Ok.

I already use the subforms. They are very convenient.

A quick thought regarding tabular input:
Maybe a Form may take a single model instance or an array of model instances.
In the first case it works as of now in the latter case it builds the form using the tabular input method described in the guide, which should work as the form already reuses CHtml to build the input elements.

With that forms and subforms could be used for tabular inputs.

The data collection of this tabular input forms could also work like the solution described in the guide.
0

#47 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 04 July 2009 - 07:43 AM

I will  think about your suggestion. Feel free to let me know if you have any other suggestions with CForm. This is new thing that we don't have much real experience yet.
0

#48 User is offline   thyseus 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 300
  • Joined: 18-April 09
  • Location:Leipzig, Germany

Posted 04 July 2009 - 08:13 PM

Hello,

is it possible to add an Widget to CForm, that automatically resolves foreign key relations? An example from the CForm-extended Blog demo:


'status'=>array(
'type'=>'dropdownlist',
'items'=>Post::model()->statusOptions,


This could be made easier, since the relation is defined in the Model, something like this:


'status'=>array(
'type'=>'foreignkey',
                                        'style'=>'dropDownList',
'fkmodel'=>'Post',
                                        'fkfield'=>'Status'


Of course, this would only generate the Options "0,1,2" - but i think there could be a lot of Situations where this Widget could be helpful.

I would highly appreciate this (or similiar) function ;)
0

#49 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 07 July 2009 - 03:33 AM

thyseus,

<?php
function allStatuses($one)
{
   return $one->Status;
}

...
'status'=>array(
   'type'=>'dropdownlist',
   'items'=>array_map('allStatuses', Post::model()->findAll(array('group'=>'Status', 'select'=>'Status'))),
)

0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • 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