[drupal-devel] Rewriting use of forms in Drupal

vlado vlado at dikini.net
Fri Jun 3 15:44:24 UTC 2005


On Fri, 2005-06-03 at 17:32 +0200, Gerhard Killesreiter wrote:
> 
> On Fri, 3 Jun 2005, vlado wrote:
> 
> >
> > > I'd rewrite the last part to
> > >
> > >  $elements['group1'] = array('type' => 'group', 'weight' => 1, 'title' =>
> > > t('some title here'));
> >
> > > And then for elements:
> > >       $elements['element1'] =  array('type'=>'textfield',
> > >  'title'=> t('element 1'), 'value' => $_POST['edit']['element1'],
> > >   'default' => $obj->element1, 'weight' => 1, 'group' => 'group1');
> >
> > How would you handle nested groups?
> 
> Do we have nested groups? Wasn't aware of this.
It can solve a lot of problems with logically extending forms, from nodeapi.
for example event->recursion rule
                 ->location->address
                 ....
> I guess a group could be member of another group:
> 
> $elements['group1'] = array('type' => 'group', 'group' => 'group2',
> 'weight' => 1, 'title' => t('some title here'));
That can work, but not sure if it will make the code simpler

Nested arrays in this case are natural to describe the form structure,
so IMO they will require less logic to do the form presentation later.





More information about the drupal-devel mailing list