Forum: Ruby on Rails link_to submit form value 2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrea C. (Guest)
on 2008-10-31 11:38
Hi to all,

I'd like to pass with a link to values inside some form. I've read in
other posts that it's possible if i include the forms inside a html
<div>...
So here it's my code of the view :

<div id="study">
<table>
        <tr><td><label for="study_titolo">Titolo di
studio</label></td></tr>
        <tr><td><label
for="study_istituto">Istituto</label></td><td><label
for="study_conseguito">Data di conseguimento</label></td><td><label
for="study_voto">Voto/giudizio</label></td></tr>
        <tr><td><%= text_field 'study', 'istituto'%></td><td><%=
date_select 'study', 'conseguito', {:include_blank =>
true}%></td><td><%= text_field 'study', 'voto'%></td></tr>
</table>
</div>

<%=link_to "Aggiungi", { :controller => "studies", :action=> "create",
:id_nominee => @nominee.id, :study => @study}, :submit => 'study', :html
=> { :method => :post} %>

where in submit value of Link_to i've specified the div id.
When i click on link_to no forms values are passed....
Can somebody help me??????
Frederick C. (Guest)
on 2008-10-31 11:47
(Received via mailing list)
On Oct 31, 9:38 am, Andrea C. <removed_email_address@domain.invalid>
wrote:
> Hi to all,
>
> I'd like to pass with a link to values inside some form. I've read in
> other posts that it's possible if i include the forms inside a html
> <div>...

That sounds made up to me. Links (without javascript help) don't
submit forms. if you have to have a link that submits a form, by far
the easiest way is to have a link whose onclick is $
('some_form').submit() (link_to_function makes this easy).

Fred
Andrea C. (Guest)
on 2008-10-31 11:56
Frederick C. wrote:
> On Oct 31, 9:38�am, Andrea C. <removed_email_address@domain.invalid>
> wrote:
>> Hi to all,
>>
>> I'd like to pass with a link to values inside some form. I've read in
>> other posts that it's possible if i include the forms inside a html
>> <div>...
>
> That sounds made up to me. Links (without javascript help) don't
> submit forms. if you have to have a link that submits a form, by far
> the easiest way is to have a link whose onclick is $
> ('some_form').submit() (link_to_function makes this easy).
>
> Fred

hi Fred,
this is the topic http://www.ruby-forum.com/topic/146247#new where i've
read the suggestion...
So i was searching the right syntax for doing that, i'll try to know
more about link_to_function, but i'd like to know if it's really
possible in the other way, cause i've found more than one person that
suggest that way...
Tanks for your reply

Andrea
Frederick C. (Guest)
on 2008-10-31 12:31
(Received via mailing list)
On 31 Oct 2008, at 09:56, Andrea C. wrote:

>>> <div>...
> i've
> read the suggestion...

That's just wrong. Probably confused by the fact that link_to_remote
does take a :submit option (which should be the id of a form element)

Fred
>
> So i was searching the right syntax for doing that, i'll try to know
> more about link_to_function, but i'd like to know if it's really
> possible in the other way, cause i've found more than one person that
> suggest that way...
> Tanks for your reply
Shandy N. (Guest)
on 2008-10-31 15:57
Andrea C. wrote:
> <%=link_to "Aggiungi", { :controller => "studies", :action=> "create",
> :id_nominee => @nominee.id, :study => @study}, :submit => 'study', :html
> => { :method => :post} %>
>
> where in submit value of Link_to i've specified the div id.
> When i click on link_to no forms values are passed....
> Can somebody help me??????

I am doing the exact thing that you are asking about the only difference
is that I am using a link_to_remote, here is my code:

<%= link_to_remote('<span>Save</span>',
  {:submit => "car_prefs", :update => 'account_car_prefs',
   :complete => 'new Effect.Pulsate(\'account_car_prefs\');',
   :url => {:action => 'car_prefs', :id => @account.id}},
  :class => "squarebutton") %>

My car_prefs div encapsulates all the textfields and dropdowns and then
the :complete just updates another div - account_car_prefs - when the
action has completed. You might also try looking at the source to make
sure that the html is being generated properly, I say this because it
seems more often then not, for me, that I always get the { } put in the
wrong place when using additional options and you can also tell if you
are using them wrong because the html doesn't get formed right.

-S
Andrea C. (Guest)
on 2008-10-31 17:19
Shandy N. wrote:

> <%= link_to_remote('<span>Save</span>',
>   {:submit => "car_prefs", :update => 'account_car_prefs',
>    :complete => 'new Effect.Pulsate(\'account_car_prefs\');',
>    :url => {:action => 'car_prefs', :id => @account.id}},
>   :class => "squarebutton") %>
>
> My car_prefs div encapsulates all the textfields and dropdowns and then
> the :complete just updates another div - account_car_prefs - when the
> action has completed. You might also try looking at the source to make
> sure that the html is being generated properly, I say this because it
> seems more often then not, for me, that I always get the { } put in the
> wrong place when using additional options and you can also tell if you
> are using them wrong because the html doesn't get formed right.
>
> -S

Hi Shandy,

really thanks for your reply.... NOw it works!!!
I was really SAD for the first answer :D now i'm better
Frederick C. (Guest)
on 2008-10-31 17:42
(Received via mailing list)
On 31 Oct 2008, at 15:19, Andrea C. wrote:

>> then
>> -S
>
> Hi Shandy,
>
> really thanks for your reply.... NOw it works!!!
> I was really SAD for the first answer :D now i'm better

Just so you're aware, the above does rely on javascript and the
prototype libraries - it won't work without javascript.

Fred
This topic is locked and can not be replied to.