Hi, This is a select * from bestemmingen where bestemming_id=''BCN''; of my database bestemming_id | naam | naam_en | landcode | airport_name | alt_naam | dist_ams | stad_zoeknaam | +---------------+-----------+-----------+----------+----------------+----------+----------+---------------+ | BCN | Barcelona | Barcelona | ES | Barcelona Arpt | NULL | 1240.3 | barcelona | I want when the visitor is on the barcelona-page the destination input is "pre-filled" with the value naam(name)+ bestemmings_id. So in case of barcelona-page html: <form action="/search" method="get"><div style="margin:0;padding:0"><input name="destination" type="hidden" value="Barcelona (BCN)" /> </form> Has anyone experience with this....? Grtz..remco -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Will you know in your controller what the destination is? If so, you
could set the value there, and then use the hidden_field form helper to
create that input you want. Something like:
# controller
place = Bestemmingen.find(params[:id])
@some_object = Search.new
@some_object.destination = "#{place.naam} (#{place.id})"
# view
<% form_for @some_object do |f| %>
<%= f.hidden_field(:destination) %>
<% end %>
Something like that anyway...
HTH,
-Roy
-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of
Remco Zwaan
Sent: Thursday, May 15, 2008 4:29 AM
To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [Rails] "pre-filled" value in form > from database
Hi,
This is a select * from bestemmingen where
bestemming_id=''BCN''; of my
database
bestemming_id | naam | naam_en | landcode | airport_name |
alt_naam | dist_ams | stad_zoeknaam |
+---------------+-----------+-----------+----------+----------------+---
-------+----------+---------------+
| BCN | Barcelona | Barcelona | ES | Barcelona Arpt |
NULL | 1240.3 | barcelona |
I want when the visitor is on the barcelona-page the destination input
is "pre-filled" with the value naam(name)+ bestemmings_id.
So in case of barcelona-page
html:
<form action="/search" method="get"><div
style="margin:0;padding:0"><input name="destination"
type="hidden"
value="Barcelona (BCN)" />
</form>
Has anyone experience with this....?
Grtz..remco
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Roy Pardee wrote:> Will you know in your controller what the destination is? If so, you > could set the value there, and then use the hidden_field form helper to > create that input you want. Something like: > > # controller > place = Bestemmingen.find(params[:id]) > @some_object = Search.new > @some_object.destination = "#{place.naam} (#{place.id})" > > # view > <% form_for @some_object do |f| %> > <%= f.hidden_field(:destination) %> > <% end %> > > Something like that anyway... > > HTH, > > -RoyHi, I don''t want this value in a hidden field, but i want that the value is filled in...in a text-field. So the visitor can see the filled in value in the form.. Grtz..remco -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Okay then--so same solution (set the attribute in the controller) just use text_field instead of hidden_field. HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Remco Zwaan Sent: Friday, May 16, 2008 12:20 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: "pre-filled" value in form > from database Roy Pardee wrote:> Will you know in your controller what the destination is? If so, you > could set the value there, and then use the hidden_field form helper > to create that input you want. Something like: > > # controller > place = Bestemmingen.find(params[:id]) > @some_object = Search.new > @some_object.destination = "#{place.naam} (#{place.id})" > > # view > <% form_for @some_object do |f| %> > <%= f.hidden_field(:destination) %> > <% end %> > > Something like that anyway... > > HTH, > > -RoyHi, I don''t want this value in a hidden field, but i want that the value is filled in...in a text-field. So the visitor can see the filled in value in the form.. Grtz..remco -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---