form problem

Hi all,

I have a form:    <%= form_tag '/admin/update_node' %>         <%= hidden_field_tag('id', showtree.id) %>         <%= text_field('name', showtree.name, {:size => 20, :value => showtree.name}) %>         <%= submit_tag('Save') %>    <% end_form_tag %>

rendered in html   <form action="/admin/update_node" method="post">        <input id="id" name="id" value="9" type="hidden">        <input id="name_SelfMate II" name="name[SelfMate II]" size="20" value="SelfMate II" type="text">        <input name="commit" value="Save" type="submit">    </form>

and the controller function   def update_node     Node.update(params[:id], {:name => params[:name]})     redirect_to(:action => index)   end

When I save, the record (name) gets returned with a lot of garbage (lines and newlines).

Can someone tell me what I'm doing wrong?

Thanks in advance Stijn

When I save, the record (name) gets ???returned??? with a lot of garbage

Your description is not precise… unable to comply :frowning:

Tarscher wrote:

Hi all,

I have a form:    <%= form_tag '/admin/update_node' %>         <%= hidden_field_tag('id', showtree.id) %>         <%= text_field('name', showtree.name, {:size => 20, :value => showtree.name}) %>         <%= submit_tag('Save') %>    <% end_form_tag %>

rendered in html   <form action="/admin/update_node" method="post">        <input id="id" name="id" value="9" type="hidden">        <input id="name_SelfMate II" name="name[SelfMate II]" size="20" value="SelfMate II" type="text">        <input name="commit" value="Save" type="submit">    </form>

and the controller function   def update_node     Node.update(params[:id], {:name => params[:name]})     redirect_to(:action => index)   end

When I save, the record (name) gets returned with a lot of garbage (lines and newlines).

params[:name] will be a Hash rather than a String because the name property of the text field is "name[SelfMate II]".

You probably want to use the text_field_tag helper rather than the text_field helper.