开发者

Why does this form not automatically populate my user's info ? Rails 3

A lot of this form has specific attributes for my payment provider, but I am trying to populate it with info from my @user object. But not working:

Specifically the :placeholder attributes on the form field under the fields_for outputs name of the attribute - in the First Name case, I see the words first_name instead of my user's first name, which 开发者_运维百科would be @user.first_name.

<%= form_for :transaction,
         :params => @result && @result.params[:transaction],
         :errors => @result && @result.errors.for(:transaction),
         :builder => ApplicationHelper::BraintreeFormBuilder,
         :url => Braintree::TransparentRedirect.url,
         :html => {:autocomplete => "off"} do |f| -%>
      <%= field_set_tag "Customer" do -%>
        <%= f.fields_for :customer, @user do |c| -%>
          <div><%= c.text_field :first_name, :placeholder => :first_name %></div>
          <div><%= c.text_field :last_name, :placeholder => :last_name %></div>
          <div><%= c.text_field :email, :placeholder => :email %></div>
        <% end -%>
<% end -%>

Thoughts ?

P.S. I have truncated the form for brevity, but there is a submit button, etc. and the form works fine. It's just not populating my info.


Whatever plugin/gem you are using to add :placeholder to your text_fields is obviously not trying to grab the value of the :first_name attribute from the object of the form builder. It probably expects an actual value only: :placeholder => @user.first_name.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜