开发者

Using a normal text link instead of a form

开发者 https://www.devze.com 2023-01-18 12:27 出处:网络
I am writing a small application using Rails 3. In one part of it there is a link (should be a link) that if clicked adds a connection between two people (see below).

I am writing a small application using Rails 3. In one part of it there is a link (should be a link) that if clicked adds a connection between two people (see below).

What I am really needing is to use a normal text link instead of a form, how is this done?

<%= form_for([@profile, @contact]) do |f| %>

    <p><%= f.hidden_field :profile_id, :value => params[:profile_id] %></p>
    <p><%= f.hidden_field :friend_id, :value => profile.id %></p>

 开发者_运维百科   <p><%= f.submit %></p>

<% end %>


Something like:

<%= link_to 'link these persons', [@profile, @contact], :method => :post, :profile_id => params[:profile_id], :friend_id => profile.id %>


You can try sumbitting the form with javascript like this:

<%= link_to 'Submit', "#", :onclick=>"('form_id').submit()"%>

This will submit your form.

0

精彩评论

暂无评论...
验证码 换一张
取 消