What I would like to have is to get a default value for the form
field (some text that the user previously entered). 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 I would like to have is to get a default value for the form
field (some text that the user previously entered). 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.
Are you sure @text contains something? What do you see if you include
something like
<%= @text %>
before the text_field_tag.
Also have a look at the html of the page (View, Page Source or similar
in browser) and see what the field html looks like. If the value is
there in the html but does not appear on screen, copy all the page
html source and enter it into the w3c html validator at The W3C Markup Validation Service and see if there are html
errors which could be confusing the browser.
Are you sure @text contains something? What do you see if you include
something like
<%= @text %>
before the text_field_tag.
I see an empty paragraph.
Also have a look at the html of the page (View, Page Source or similar
in browser) and see what the field html looks like. If the value is
there in the html but does not appear on screen, copy all the page
html source and enter it into the w3c html validator athttp://validator.w3.org/#validate_by_inputand see if there are html
errors which could be confusing the browser.
It did NOT validate. This is one of the errors,
Line 59, Column 31: character “[” is not allowed in the value of
attribute “id”
Are you sure @text contains something? What do you see if you include
something like
<%= @text %>
before the text_field_tag.
I see an empty paragraph.
In that case @text is empty, so that is the problem to be fixed.
Unless the error below is causing it to show empty which does not seem
likely.
If you have trouble working out why @text is empty it may be worth
while having a look at the RoR guide on Debugging at http://guides.rubyonrails.org. I find ruby-debug very useful when
code inspection does not reveal the problem.
attribute “id”
</textar
It is possible that you violated the naming convention for this
attribute. For example, id and name attributes must begin with a
letter, not a digit.
You will have to not include [ ] in your name string.