[html-formfu] Repeatable block will not save records

Ascii King tech at swattermatter.com
Mon Jan 12 20:39:50 GMT 2009


I have found a solution to my problem. A friend of mine googled the
problem and I found an example bit of code that I had not run into before.

      counter_name: count

This needs to be added so that the following field will work properly.

                  - type: Hidden
                    name: count

This isn't in any example or documentation that I had read so far and I
read a lot of them. Here is my understanding of this issue.

I could not write to any record other than the first one in a has_many
relationship. The answer is that I needed to add a counter_name option
to the form config file. For example:

    element:
      - type: Repeatable
        nested_name: authors
        counter_name: count
        model_config:
          new_empty_row_multi: author

        elements:
          - type: Hidden
            name: id

          - type: Text
            name: author

      - type: Hidden
        name: count

The documentation says that the "- type: Hidden" is only needed if you
want to add multiple new empty rows (new_empty_row_multi), but in my
experience, this isn't true. You need it and the counter_name line if
you have more than one row.


Ascii King wrote:
> I started from scratch using the updated Catalyst tutorial and reread 
> the documentation.  The model_stash problem makes more sense now. I 
> have set it in the MyApp.conf file. I am still guessing that the 
> ModelName is supposed to be 'DB'.  However, even starting from scratch 
> and only adding the bare minimum of code to create a has_many form, I 
> still cannot get it to update anything beond the first record.
>
> Does someone have a sample project they could send me that includes a 
> working has_many form?
>
> Thanks for the help so far. This is the last project I have to do 
> before I change jobs and I would like to leave it a success.
>
>> If I used the following line to set up the model:
>>
>> $ script/omtsweb_create.pl model DB DBIC::Schema OMTSWeb::Schema
>> create=static dbi:SQLite:omtsweb.db
>>
>> then my ModelName is 'DB'?
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>




More information about the HTML-FormFu mailing list