Nested Forms

76 views
Skip to first unread message

basex

unread,
Apr 4, 2011, 6:13:20 PM4/4/11
to Padrino Framework
Can anyone give me an example of the controller that handles the form
submit for Nested Forms?

The example would be very helpful if it was added to the guides
http://www.padrinorb.com/guides/application-helpers

Darío Javier Cravero

unread,
Apr 5, 2011, 9:20:29 AM4/5/11
to Padrino Framework
Hi basex,

Here's a quick example using Padrino's admin you can look at:
https://github.com/dariocravero/Padrino-nested-forms-example.

I haven't used this functionality before since it wasn't available
until 0.9.21 but now that I did, I couldn't find a faster way (apart
from the one implemented on the example) to provide a placeholder for
a new address: I just add a new address every time you edit or create
a new record. I also don't know what to do with that record if it's
blank.

ActiveRecord's :reject_if => :all_blank should work (as stated here
http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html)
but either I'm not using it properly or it just doesn't work here.

Now, the approach I've taken to achieve that isn't the best and I know
that. I'm sure there's a best way to do it and I'd love to see this
example improved. :)

Cheers!
Darío

basex

unread,
Apr 13, 2011, 6:38:46 AM4/13/11
to Padrino Framework
Thanks Dário. Your code was very useful. I'm trying to do the same
with datamapper.

That part of creating a new object to get an empty address seems to be
a very good idea.

Cheers

On Apr 5, 9:20 am, Darío Javier Cravero <da...@q-innova.com.ar> wrote:
> Hi basex,
>
> Here's a quick example using Padrino's admin you can look at:https://github.com/dariocravero/Padrino-nested-forms-example.
>
> I haven't used this functionality before since it wasn't available
> until 0.9.21 but now that I did, I couldn't find a faster way (apart
> from the one implemented on the example) to provide a placeholder for
> a new address: I just add a new address every time you edit or create
> a new record. I also don't know what to do with that record if it's
> blank.
>
> ActiveRecord's :reject_if => :all_blank should work (as stated herehttp://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/Clas...)
Reply all
Reply to author
Forward
0 new messages