Tag: 嵌套表单

symfony2多重嵌套表单原型

我想在另一个集合types中包含一个集合types。 它应该是这样的: 使用只有一个集合工作正常,但我需要编辑外部窗体的原型,所以它呈现每行的内部forms的原型。 任何想法我怎么能做到这一点? 另外什么是最好的方式来保存 编辑:现在我想呈现嵌套的窗体的原型: <ul class="characteristics-container" data-prototype="{{ form_widget(form.characteristics.vars.prototype)|e }}" data-prototype-options="{{ form_widget(form.characteristics.options.vars.prototype|e ) }}"> {# iterate over each existing tag and render its only field: name #} {% for characteristic in form.characteristics %} <li>{{ form_row(characteristic.name) }}</li> <div class="characteristics-options"> {% for opt in form.characteristics.options %} {% endfor %} </div> {% endfor %} </ul> 它在form_widget(form.characteristics.options.vars.prototype|e Method […]

Rails的 – 使用form_for和fields_for,你如何访问子对象,而在fields_for块?

在我的第一个rails应用程序中,我试图使用form_for和fields_for来创build一个嵌套的对象窗体。 到目前为止这么好,但我无法弄清楚如何在fields_for块中访问子对象。 我已经预先在子对象中填充了一个字段,其中要显示用户指令中的数据。 楷模 车库: has_many :cars, :dependent => :destroy accepts_nested_attributes_for :cars 汽车: belongs_to :garage 车库控制器 def new @garage = Garage.new for i in 1..5 @garage.cars.build :stall_number => i end end _form.html.erb <%= form_for @garage do |f| %> <%= f.label :title, "Garage Name" %><br /> <%= f.text_field :title %> <% f.fields_for :cars do |builder| %> […]

Rails的嵌套窗体has_many:通过,如何编辑连接模型的属性?

如何在使用accept_nested_attributes_for时编辑连接模型的属性? 我有3个模型:由连接器join的主题和文章 class Topic < ActiveRecord::Base has_many :linkers has_many :articles, :through => :linkers, :foreign_key => :article_id accepts_nested_attributes_for :articles end class Article < ActiveRecord::Base has_many :linkers has_many :topics, :through => :linkers, :foreign_key => :topic_id end class Linker < ActiveRecord::Base #this is the join model, has extra attributes like "relevance" belongs_to :topic belongs_to :article end 所以,当我在主题控制器的“新”动作中构build文章… @topic.articles.build […]

你可以嵌套的HTML表单?

是否有可能像这样嵌套的HTML表单 <form name="mainForm"> <form name="subForm"> </form> </form> 所以这两个表格工作? 我的朋友有这个问题,子subForm的一部分工作,而另一部分则没有。