Nested Forms

已查看 76 次
跳至第一个未读帖子

basex

未读,
2011年4月4日 18:13:202011/4/4
收件人 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

未读,
2011年4月5日 09:20:292011/4/5
收件人 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

未读,
2011年4月13日 06:38:462011/4/13
收件人 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...)
回复全部
回复作者
转发
0 个新帖子