<html><body bgcolor="#FFFFFF"><div><br><br>Am 05.03.2009 um 15:40 schrieb Leanan Sidhe <<a href="mailto:the.leanan.sidhe@gmail.com">the.leanan.sidhe@gmail.com</a>>:<br><br></div><div></div><blockquote type="cite"><div><br><br><div class="gmail_quote">On Thu, Mar 5, 2009 at 8:46 AM, Ascii King <span dir="ltr"><<a href="mailto:tech@swattermatter.com"><a href="mailto:tech@swattermatter.com">tech@swattermatter.com</a></a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For starters, I don't think it is supposed to be "schema = DB", just "schema DB"<div class="im"><br>
<br>
<Controller::HTML::FormFu><br>
<model_stash><br>
schema DB<br>
</model_stash><br>
</Controller::HTML::FormFu><br>
<br></div>
Also, could you show us the may_have line that sets up the 'debits' relationship?</blockquote><div><br>I meant might_have, not may_have, and here it is:<br>In MyApp::DB::Result::Account :<br><br>__PACKAGE__->might_have(<br>
'debits' => 'MyApp::Schema::DB::Result::Debit',<br> 'account_id'<br>);<br><br>Where both the Account and Debit Tables have an account_id field. It's definitely walking this relationship, because my form is loading the "something" and "something_else" values. It's just not going that extra step and loading all the related debit_items for that debit. In case you are curious, that is set up like so:<br>
<br>in MyApp::DB::Result::Debit :<br><br>__PACKAGE__->has_many(<br> 'debit_items' => 'MyApp::Schema::DB::Result::DebitItems',<br> 'debit_id'<br>);<br><br>Where both Debit and DebitItems table have a debit_id column. This is where it breaks. For my example, there is a row with debit_id 1 in Debit, and 3 rows in DebitItems with a debit_id of 1 that should match up. Those three rows are not being loaded from the database. It's not even giving me 3 empty rows.<br>
<br>Should DB in my myapp.conf be DB::Result, instead, since all my table files are MyApp::Schema::DB::Result::xxx? I've tried that, too, and it doesn't seem to make a difference.<br><br>My controller has the following:<br>
sub testing :FormConfig('MyApp/myapp_base.yml') :PathPart('testing') Chained('/') Args(0) {<br> my ($self, $c) = @_;<br> my $form = $c->stash->{'form'};<br><br> if ($form->submitted_and_valid) {<br>
$form->model->update([still trying to figure out what to put here but my first concern is getting loading working]);<br> } else {<br> $form->model->default_values($c->model('DB::Account')->find(1));<br>
}<br>}<br><br>Obviously I'll make it a bit more dynamic later on, but this is just for testing purposes with some dummy data in the db.<br><br>Please let me know if there's anything else I can tell you that would make it easier for you to figure out (except of course the original code, since that's proprietary)<br>
<br>Thanks.<br><br><br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
Leanan Sidhe wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
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:<br>
<br>
<br>
I have something along the following for my tables:<br>
<br>
MyApp::DB::Result::Account:<br>
- A may_have for MyApp::DB::Result::Debit, named debits<br>
<br>
MyApp::DB::Result::Debit<br>
- A belongs_to for MyApp::DB::Result::Account, named account<br>
- A has_many for MyApp::DB::Result::DebitItems, named debit_items<br>
<br>
MyApp::DB::Result::DebitItems<br>
- A belongs_to for MyApp::DB::Result::Debit, named debit<br>
<br>
myapp.conf has:<br>
name MyApp<br>
<Controller::HTML::FormFu><br>
<model_stash><br>
schema = DB<br>
</model_stash><br>
</Controller::HTML::FormFu><br>
<br>
(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)<br>
<br>
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:<br>
<br>
---<br>
elements:<br>
nested_name: debits<br>
elements:<br>
- type: Block<br>
tag: table<br>
.... (lots of stuff building out the headers, etc. Then I finally get to the rows)<br>
- type: Block<br>
tag: tbody<br>
elements:<br>
- type: Repeatable<br>
nested_name: debit_items<br>
elements:<br>
- type: Block<br>
... (lots of stuff building out the row I want repeated)<br>
<br>
<br>
<br>
When I load the form, I do $form->model->default_values($c->model('DB::Account')->find(1));<br>
<br>
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.<br>
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.<br>
<br>
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?<br>
<br>
Thank you!<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
HTML-FormFu mailing list<br>
<a href="mailto:HTML-FormFu@lists.scsys.co.uk" target="_blank"><a href="mailto:HTML-FormFu@lists.scsys.co.uk">HTML-FormFu@lists.scsys.co.uk</a></a><br>
<a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu" target="_blank"><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu</a></a><br>
</blockquote>
<br>
_______________________________________________<br>
HTML-FormFu mailing list<br>
<a href="mailto:HTML-FormFu@lists.scsys.co.uk" target="_blank"><a href="mailto:HTML-FormFu@lists.scsys.co.uk">HTML-FormFu@lists.scsys.co.uk</a></a><br>
<a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu" target="_blank"><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu</a></a><br>
</blockquote></div><br>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>HTML-FormFu mailing list</span><br><span><a href="mailto:HTML-FormFu@lists.scsys.co.uk">HTML-FormFu@lists.scsys.co.uk</a></span><br><span><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu</a></span></div></blockquote><br><div><br></div><div>You could write a test. Have a look at the formfu model dbic test suite. This will help you. There are already many defined which you can use. </div><div><br></div><div>If I recall correctly I had this problem too. </div></body></html>