Link_to submit form value 2


#1

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

... So here it's my code of the view :
Titolo di studio
Istituto Data di conseguimento Voto/giudizio
<%= text_field 'study', 'istituto'%> <%= date_select 'study', 'conseguito', {:include_blank => true}%> <%= text_field 'study', 'voto'%>

<%=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???


#2

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

...

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


#3

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

...

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


#4

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(‘Save’,
{: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


#5

On 31 Oct 2008, at 09:56, Andrea C. wrote:

...

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


#6

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 :smiley: 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


#7

Shandy N. wrote:

<%= link_to_remote(‘Save’,
{: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 :smiley: now i’m better