Tuesday, September 21, 2010

CakePHP 1.3 Form Helper inputs - how can I dynamically add items to the form?

I have a form which I'm using echo $this->Form->inputs(array( ... very
successfully... I have a related model with potential linked items. In
the edit form I would like to dynamically add several fields so I can
edit the related items. I know I need to use naming for the field such
as Model.0.fieldname, Model.1.fieldname etc....How can I dynamically
insert all these fields in my form? See below:

echo $this->Form->inputs(array(
'legend' => 'Legend Description Here',
'Model.id',
'ModelTwo.0.fieldname1' => array(
'label' => array('text' => 'Order', 'class' => 'req')
),
'ModelTwo.0.name' => array(
'label' => array('text' => 'Product Name', 'class' =>
'req'),
'size' => 100
),
'ModelTwo.1.fieldname1' => array(
'label' => array('text' => 'Order', 'class' => 'req')
),
'ModelTwo.1.name' => array(
'label' => array('text' => 'Product Name', 'class' =>
'req'),
'size' => 100
),

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: