-- Sagi Bashari <
sagi@...> wrote
(on Tuesday, 01 July 2008, 02:31 PM +0300):
> I can add a counter, but I can't see a good use for it - its value should be
> identical to count($_POST['features']).
>
> And I will have to iterate over the features anyway to add the second level of
> sub-forms (ItemForm).
This sounds like a reasonable solution to me, actually.
> On Tue, Jul 1, 2008 at 2:10 PM, Bart McLeod <
mcleod@...> wrote:
>
> I would do like you do, inspect the post data. However, it would be nice if
> you would just have to know the number of subforms you are processing.
> Javascript can easily update a counter in a hidden field on your mainform.
> It increments the count each time you add a subform dynamically. This
> counter is the only post element you will have to evaluate in order to know
> how many subforms to process.
>
> Bart McLeod
>
> Sagi Bashari schreef:
>
>
> Hello,
>
> I have a form that can generate any number of input fields dynamically
> (the fields are generated using javascript).
>
> The fields have some nested sub-form structure:
> 1. There can be many "feature" forms, and each has a name: features
> [feature0,..,featureN][name]
> 2. Each of these feature forms has many items, and each item has a
> name: features[feature0][items][item0,..,itemN][name]
>
> (Actually they have many other fields except the name but this is
> enough for the example).
>
> I managed to handle a static number of such sub-forms with Zend_Form,
> by attaching multiple instances of a FeatureForm to my main form, and
> attaching multiple instances of ItemForm to the FeatureForm (inside a
> container sub-form).
>
> However, I wonder how can I add these sub-forms dynamically.
>
> I thought about creating some pre-processing method that will get the
> $_POST data, inspect it and add fields accordingly before calling
> isValid().
>
> Can anyone think of a better (more Zend_Form-like) way of handling such
> situation?
>
> Thanks,
> Sagi
>
>
--
Matthew Weier O'Phinney
Software Architect |
matthew@...
Zend Framework |
http://framework.zend.com/