Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

FormFu, DBIC, and multiple tables

by uG (Scribe)
on Mar 30, 2010 at 20:03 UTC ( #831942=perlquestion: print w/ replies, xml ) Need Help??
uG has asked for the wisdom of the Perl Monks concerning the following question:

I've been messing with FormFu, and am having a problem with the following config:
<elements> name title type Text label Post title <model_config> resultset Sets delete_if_empty 1 </model_config> </elements> <elements> name display type Text label Shortened Affiliate Link <model_config> resultset Affiliates delete_if_empty 1 </model_config> </elements>
Each element needs to load/update from a different resultset model. To load the values into the form I am having to call default_values($result_set_row) for each table (in this case, twice). When I update, I do basically the same thing, but then I ran into the problem of having rows with empty values instead of the row being deleted. Now I could call a delete on the row, but FormFu has a model_config option called delete_if_empty. Setting this, it deletes everything I call an update on (in this case, 2 updates, one for each table) instead of just the table that is defined in the element tags under resultset. Do I have to check the values myself, and delete the rows if needed? Or is there some config i'm misunderstanding/not setting for FormFu that will make it 'Just Work'? :)

Comment on FormFu, DBIC, and multiple tables
Download Code
Re: FormFu, DBIC, and multiple tables
by Anonymous Monk on Mar 31, 2010 at 03:31 UTC
      <model_config> resultset Sets delete_if_empty 1 </model_config>
      delete_if_empty deletes all rows that are related instead of just the row set in resultset. I want it to just delete the row it belongs to.
        I don't see how that is a perl program, code I can run and test and possibly understand.
Re: FormFu, DBIC, and multiple tables
by fireartist (Chaplain) on Apr 01, 2010 at 08:24 UTC

    'delete_if_empty' is for a 'might_have' row related to the root row passed to default_values().

    In your case, you'll need code in your controller to check for the lack of a value, and call delete() yourself.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://831942]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-08-20 15:43 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (118 votes), past polls