Skip Menu |

This queue is for tickets about the HTML-FormFu-Model-DBIC CPAN distribution.

Report information
The Basics
Id: 53887
Status: new
Priority: 0/
Queue: HTML-FormFu-Model-DBIC

People
Owner: Nobody in particular
Requestors: mzrinsky [...] redanvil.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.06000
Fixed in: (no value)



Subject: creating related records.
We have a schema something like the following.. Company (id, address_id) Address (id, street, etc.) Company has a relationship, __PACKAGE__->belongs_to( 'address', 'Schema::Result::Address', { 'foreign.id' => 'self.address_id' }, ); We then have a form, which will create a company, and its address all in one shot, which has - type: Fieldset legend: "Company Address" nested_name: address This all works fine, the company record will be created, and the address record will be created, however the address record will NOT be associated with the company record. (i.e. address_id in company will not be set to the id of the newly created address record.) Attached is a patch that fixes the issue, but I can't take credit for it, as it was on the mailing list in Nov '08. http://lists.scsys.co.uk/pipermail/html-formfu/2008-November/001505.html
Subject: formfu_belongsto.diff
Index: lib/HTML/FormFu/Model/DBIC.pm =================================================================== --- lib/HTML/FormFu/Model/DBIC.pm (revision 1226) +++ lib/HTML/FormFu/Model/DBIC.pm (working copy) @@ -369,6 +369,7 @@ _save_columns( $base, $dbic, $form ) or return; $dbic->update_or_insert; + $dbic->discard_changes; _save_relationships( $self, $base, $dbic, $form, $rs, $attrs, \@rels ); @@ -449,6 +450,9 @@ nested_base => $rel, from => $dbic->result_class, } ); + + $dbic->set_from_related( $rel, $target ); + $dbic->update(); } } }