team-formalist / formalist-rb

Flexible form builder
MIT License
22 stars 4 forks source link

Return an empty array for any empty many blocks #56

Closed dylanwolff closed 7 years ago

dylanwolff commented 7 years ago

Given the following example many block:

many :left_masthead_menu_groups,
  label: "Left masthead menu groups",
  action_label: "Add a menu group",
  placeholder: "The left masthead doesn't have any menu groups yet." do
  select_box :menu_group_id,
    options: dep(:menu_groups_list),
    label: "Menu group"
end

When submitting the form with a value set in the :menu_group_id select box, the following attributes are posted:

{"left_masthead_menu_groups"=>[{"__rack_workaround"=>"", "menu_group_id"=>"2"}]}

However, when a value is not selected, attributes is nil. Ideally an empty array would be returned here.

timriley commented 7 years ago

Moved to https://github.com/icelab/formalist-standard-react/issues/105