[html-formfu] Bug with re-occuring nested related tables with CP FormFu?

Toby Corkindale toby.corkindale at strategicdata.com.au
Mon Jun 1 01:32:19 GMT 2009


Mario Minati wrote:
> Am Freitag 29 Mai 2009 10:41:30 schrieb Toby Corkindale:
>> Hi,
>> I'm using FormFu in Catalyst, with a DBIC schema, and have a problem
>> with a particular usage of nested relationships in the form.
>>
>> The table in question has a might_have relationship with another table,
>> let's say like:
>> book (id, title, blurb)
>> book_extra (book_id, num_pages, in_stock)
>>
>> Now, I setup a form like:
>> ---
>> elements:
>>    - name: title
>>      type: Text
>>    - type: Block
>>      tag: div
>>      nested_name: book_extra
>>      elements:
>>        - name: num_pages
>>          type: Text
>>    - name: blurb
>>      type: Textarea
>>    - type: Block
>>      tag: div
>>      nested_name: book_extra
>>      elements:
>>        - name: in_stock
>>          type: Checkbox
>>
>> -----------------------------
>>
>> The idea being that num_pages and in_stock are sent to the related table
>> instead.
>>
>> This *does* work for the first nested item, in this case num_pages.
>> However the second time it comes up, it doesn't do anything - ie.
>> in_stock is never saved to the DB.
>> If I move the in_stock element higher up, in the same Block as
>> num_pages, then it does work.
>>
>> Is this a known bug/limitation, or is this supposed to work?
>> Am I doing something wrong?
> 
> Hi toby,
> 
> this is probaply a limitation of the current implementation of FF::M::DBIC.
> 
> In line 464 (rev. 1525) we only look for the *first* element with a specific 
> nested_name attribute.
> 
> So you need to rewrite your form to only include one block with a given 
> nested_name.

Thanks Mario.

Is there any way I can rewrite my form to include only one nested_name 
block.. but still have the nested elements interspersed with the 
non-nested elements?

I ask, because I am trying to implement a form which looks a bit like this..

fieldset:
   input (first table)
   input (first table)
   input (second table)
   input (second table)

fieldset:
   input (first table)
   input (second table)
   input (second table)

fieldset:
   input (first table)
   input (second table)
   input (second table)



The reason it's setup this way is because there are several forms.. They 
all have the (first table) inputs on them, but each form has different 
(second table) info. (It does result in a normalised database schema, 
which is good.)

ta,
Toby



More information about the HTML-FormFu mailing list