Hi,
I would like to do the following.
In a form, an attribute is a belongs_to association, so user selects a
drop down list. But I would like user to add his own value if needed.
For that I have added a ‘Add value…’ as last item. Then with an
observer, I am replacing the DDL by remote form (text and button). So,
when users adds value, ajax call adds the value in the model, and
replace the remote form by the DDL, with the new value.
My problem is in the remote form. It seems I cannot add a remote form
within a form (helper is not generated at all).
What’s wrong here? Is there any other possiblity (adding an observer on
the button)?
Thank you for your help,
JE
Hi Jean-Etienne,
Jean-Etienne D. wrote:
It seems I cannot add a remote form
within a form (helper is not generated at all).
That’s correct. Forms cannot contain other forms. The W3C spec spells
it
out quite clearly.
The solution I’ve used in a situation similar to yours is to use Ajax
for
all the inputs (rendering a checkbox_tag with an associated
observe_field,
for example) with an empty form_remote_tag’s submit button for page
redirection. It looks and acts like a single form to the user.
Potentially
puts a heavier burden on you for form-level validation, though, since
you’re
updating the model incrementally.
hth,
Bill
I tried to go for an oberver on a input (type button), but
observer_field does not generate any html… This is included in a
partial (coming from another observer action)
Did I do somehting wrong?
Jean-Etienne D. wrote:
I tried to go for an oberver on a input (type button),
but observer_field does not generate any html… This
is included in a partial (coming from another observer
action) Did I do somehting wrong?
Hard to tell without seeing your code
Right Just wanted to have a confirmation that having an observe_field
in a form is possible.
Or may I send you some code by mail?
Etienne
Jean-Etienne D. wrote:
Or may I send you some code by mail?
My personal experience is that moving problem code over to my sandbox,
paring it down to the bare essentials, using irb to investigate the
behavior
of specific methods, etc., more often than not shows me the problem and
how
to fix it. If need be, you can send along some code.
Best regards,
Bill