Link_to :post true Newbie question


#1

Hi All,

I am attempting to use a link_to helper to perform a form post using the
following construct:

<%= link_to ‘Save’, {:action =>‘create’}, :post => true %>

What I find is the parameters passed to the webserver are empty. My
model validation stuff triggers indicating the fields in question are
empty too. This is to create a new DB entry so no ID is being passed,
although there are a few required parameters obviously.

This works fine if I use:

<%= submit_tag “Create” %>

So do I need to specify the parameters as part of the link_to?

ROR 1.2.2

Any help is appreciated,
Rick


#2

This works fine if I use:

<%= submit_tag “Create” %>

View the source of your page. Using link_to with :post => true will
turn
that link into a mini-form that knows nothing at all about your other
form
on the site.

If you don’t want an actual submit button, then you’ll need to use
link_to_function and set the function to do document.myform.submit() or
some such.

-philip