Value for text_field_tag ?

T

T_P

Hi!

I have this in my controller:
@text = params[:data][:text]

In the view, I have this code:
<%= label_tag('data[text]', "Word/phrase: ") %> <br />
<%= text_field_tag( 'data[text]', @text, :size => 40, :maxlength =>
254 ) %>

What I would like to have is to get a default value for the form
field. I cannot figure out why @text controller instance variable
doesn't work. It's a non-empty string, but the corresponding form
field is always blank. :-(

However, this piece of code always works,
<%= text_field_tag( 'data[text]', 'STATIC STRING', :size =>
40, :maxlength => 254 ) %>

What am I missing here? :-/

Tuo
 
I

Iñaki Baz Castillo

El Lunes, 21 de Diciembre de 2009, T_P escribi=F3:
Hi!
=20
I have this in my controller:
@text =3D params[:data][:text]
=20
In the view, I have this code:
<%=3D label_tag('data[text]', "Word/phrase: ") %> <br />
<%=3D text_field_tag( 'data[text]', @text, :size =3D> 40, :maxlength = =3D>
254 ) %>
=20
What I would like to have is to get a default value for the form
field. I cannot figure out why @text controller instance variable
doesn't work. It's a non-empty string, but the corresponding form
field is always blank. :-(
=20
However, this piece of code always works,
<%=3D text_field_tag( 'data[text]', 'STATIC STRING', :size =3D>
40, :maxlength =3D> 254 ) %>
=20
What am I missing here? :-/

Please, ask in a list of RubyOnRails.


=2D-=20
I=F1aki Baz Castillo <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,431
Latest member
ElyseG3173

Latest Threads

Top