[html-formfu] Repeatable block will not save records

David Schmidt davewood at gmx.at
Mon Jan 19 21:17:43 GMT 2009


I have been looking for this solution for days now. Thank you so much.

Related to this problem.
If a constraint of one of the repeatable elements fails, the form is
re-displayed but the error message is not displayed.

info:
project has_many pictures
picture belongs_to project

# projects/create.yml

  - type: Hidden
    name: count

  - type: Repeatable
    counter_name: count
    nested_name: pictures
    elements:
      - type: Hidden
        name: id
      - type: Text
        name: title
      - type: Text
        label: Position
        name: position
        constraints:
          - type: Integer
            message: Position must be an Integer



Another thing, when I have no Repeatable present (thats the case when
I create a new instance of the object related to the form) I dont want
an empty Repeatable block. Is there a way other then having 2 seperate
form configs?

greetings
david

On Mon, Jan 12, 2009 at 9:39 PM, Ascii King <tech at swattermatter.com> wrote:
> 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
>>
>
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>



-- 
David Schmidt   |   http://www.fm5.at



More information about the HTML-FormFu mailing list