<html><body bgcolor="#FFFFFF"><div><br><br>Am 05.03.2009 um 15:40 schrieb Leanan Sidhe &lt;<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">&lt;<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>
&lt;Controller::HTML::FormFu><br>
 &nbsp; &lt;model_stash><br>
 &nbsp; &nbsp; &nbsp; schema DB<br>
 &nbsp; &lt;/model_stash><br>
&lt;/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>
&nbsp;&nbsp; 'debits' => 'MyApp::Schema::DB::Result::Debit',<br>&nbsp; 'account_id'<br>);<br><br>Where both the Account and Debit Tables have an account_id field.&nbsp; It's definitely walking this relationship, because my form is loading the "something" and "something_else" values.&nbsp; It's just not going that extra step and loading all the related debit_items for that debit.&nbsp; In case you are curious, that is set up like so:<br>
<br>in MyApp::DB::Result::Debit :<br><br>__PACKAGE__->has_many(<br>&nbsp; 'debit_items' => 'MyApp::Schema::DB::Result::DebitItems',<br>&nbsp; 'debit_id'<br>);<br><br>Where both Debit and DebitItems table have a debit_id column.&nbsp; This is where it breaks.&nbsp; 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.&nbsp; Those three rows are not being loaded from the database.&nbsp; 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?&nbsp; 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>&nbsp; my ($self, $c) = @_;<br>&nbsp; my $form = $c->stash->{'form'};<br><br>&nbsp; if ($form->submitted_and_valid) {<br>
&nbsp;&nbsp;&nbsp; $form->model->update([still trying to figure out what to put here but my first concern is getting loading working]);<br>&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; $form->model->default_values($c->model('DB::Account')->find(1));<br>
&nbsp; }<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. &nbsp;Everything except for my repeatables are loading from the db, and I am at a loss as to why this is. &nbsp;My guess is that either 1) What I want to do cannot currently be done, or 2) I'm missing something simple, but important. &nbsp;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>
&nbsp;- 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>
&lt;Controller::HTML::FormFu><br>
 &nbsp;&lt;model_stash><br>
 &nbsp; &nbsp;schema = DB<br>
 &nbsp;&lt;/model_stash><br>
&lt;/Controller::HTML::FormFu><br>
<br>
(I'm not sure if that is right. &nbsp;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. &nbsp;In one of the sub configs where I'm trying to get this working I have something like this:<br>
<br>
---<br>
 &nbsp;elements:<br>
 &nbsp;nested_name: debits<br>
 &nbsp;elements:<br>
 &nbsp; - type: Block<br>
 &nbsp; &nbsp; tag: table<br>
 &nbsp; &nbsp; &nbsp; &nbsp;.... (lots of stuff building out the headers, etc. &nbsp;Then I finally get to the rows)<br>
 &nbsp; - type: Block<br>
 &nbsp; &nbsp; tag: tbody<br>
 &nbsp; &nbsp; elements:<br>
 &nbsp; &nbsp; &nbsp; - type: Repeatable<br>
 &nbsp; &nbsp; &nbsp; nested_name: debit_items<br>
 &nbsp; &nbsp; &nbsp; elements:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; - type: Block<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ... (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. &nbsp;I'll have things like debits.something, debits.soemthing_else (where I have something and something_else columns in the debit table) &nbsp;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). &nbsp;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. &nbsp;Is this possible, or am I dreaming? &nbsp;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.&nbsp;</div><div><br></div><div>If I recall correctly I had this problem too.&nbsp;</div></body></html>