"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 |

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

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,

-Roy

Hi,

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

Okay then--so same solution (set the attribute in the controller) just
use text_field instead of hidden_field.

HTH,

-Roy