访问semantic_fieds_for循环/formtastic中的对象
模型具有 Accepts_nested_attributes_for 关系,形式如下:
= semantic_form_for @obj, :url => path do |f|
= f.inputs do
= f.input :name
= f.semantic_fields_for :photos do |p|
= p.inputs :desc
= f.buttons
该形式运行良好,一切都很好。但是,我想在现场附近显示每张照片,以便用户可以知道她要注释哪张照片。无论如何,要在 fields_for 循环内访问 photo.id 吗?
编辑:
有什么方法可以改变本示例中照片字段的渲染顺序。据我所知,到目前为止,这个顺序是相当随机的。
Model has accepts_nested_attributes_for for the relation and the form is as follows:
= semantic_form_for @obj, :url => path do |f|
= f.inputs do
= f.input :name
= f.semantic_fields_for :photos do |p|
= p.inputs :desc
= f.buttons
The form works well and everything is fine. However, I would like to display each photo near the field, so the user could se which picture she is going to annotate. Is there anyway, to access photo.id inside the fields_for loop?
Edit:
Is there any way to alter the order in which photos fields will be rendered in this example. As far as I can tell till now, that order is pretty random.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这很简单,可以通过以下方式访问该对象:
:-)
问题的第二部分通过以下方式解决:
Well this was easy enough, the object is accesible by:
:-)
Second part of the question is solved with: