[html-formfu] Having issues with nested repeatable loading from
db.
Ascii King
tech at swattermatter.com
Thu Mar 5 13:46:33 GMT 2009
For starters, I don't think it is supposed to be "schema = DB", just
"schema DB"
<Controller::HTML::FormFu>
<model_stash>
schema DB
</model_stash>
</Controller::HTML::FormFu>
Also, could you show us the may_have line that sets up the 'debits'
relationship?
Leanan Sidhe wrote:
> I'm attempting to make use of the $form->model->default_values and
> $form->model->update methods. Everything except for my repeatables
> are loading from the db, and I am at a loss as to why this is. My
> guess is that either 1) What I want to do cannot currently be done, or
> 2) I'm missing something simple, but important. Here's an example of
> what I am trying to do:
>
>
> I have something along the following for my tables:
>
> MyApp::DB::Result::Account:
> - A may_have for MyApp::DB::Result::Debit, named debits
>
> MyApp::DB::Result::Debit
> - A belongs_to for MyApp::DB::Result::Account, named account
> - A has_many for MyApp::DB::Result::DebitItems, named debit_items
>
> MyApp::DB::Result::DebitItems
> - A belongs_to for MyApp::DB::Result::Debit, named debit
>
> myapp.conf has:
> name MyApp
> <Controller::HTML::FormFu>
> <model_stash>
> schema = DB
> </model_stash>
> </Controller::HTML::FormFu>
>
> (I'm not sure if that is right. I've tried MyApp::Model::DB, and
> MyApp::Schema::DB -- Model::DB lists the connection string, Schema::DB
> is the one with the load_namespaces)
>
> My form config has a base config file that loads a bunch of sub config
> files. In one of the sub configs where I'm trying to get this working
> I have something like this:
>
> ---
> elements:
> nested_name: debits
> elements:
> - type: Block
> tag: table
> .... (lots of stuff building out the headers, etc. Then I
> finally get to the rows)
> - type: Block
> tag: tbody
> elements:
> - type: Repeatable
> nested_name: debit_items
> elements:
> - type: Block
> ... (lots of stuff building out the row I want repeated)
>
>
>
> When I load the form, I do
> $form->model->default_values($c->model('DB::Account')->find(1));
>
> The portion of the form that is not in the repeatable section loads
> fine. I'll have things like debits.something, debits.soemthing_else
> (where I have something and something_else columns in the debit
> table) All the data for those fields loads from the database just fine.
> The form builds out a table with one empty row, where the names are
> debits.debit_item.value, debits.debit_item.date, etc etc (where I have
> value and date columns in the debititems table). However, the fields
> aren't populated from the database.
>
> As far as I can tell I've got everything right, but obviously I don't
> because it just doesn't work. Is this possible, or am I dreaming? If
> it's possible, what am I messing up?
>
> Thank you!
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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