Using Arrays in Simple_form

随声附和 提交于 2019-12-11 03:39:28

问题


Using Rails 4.1.5 and simple_form, 3.0.2 and Postgresql, I have declared an array, rsvp_options in the functions table. Following stAndres answer, I did the following

<%= simple_form_for @function do |f| %>
  <%= f.input_field :rsvp_options, multiple: true %>
  <%= f.input_field :rsvp_options, multiple: true %>
  <%= f.button :submit , class: 'btn btn-primary'%>
<% end %>

If @function.rsvp_options is initalised with ['test1','test2'], then simple form displays two boxes, but both ones have {'test1','test2'} in them. If @function.rsvp_options is initialised with [], then both boxes have {} in them. Also, there is no label for the boxes.

Apart from this, simple_form actually works, in the sense that if I put text into each box, then the rsvp_options variable is updated properly. In other words, the only problem is with the display of the information, not the handling of it into params.

So, how do I use simpleform to properly display the array data and also give a label for it?


回答1:


This open issue would seem to indicate that simple_form does not support arrays at the present time.



来源:https://stackoverflow.com/questions/27412086/using-arrays-in-simple-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!