You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This one is a bit of a doozy. I'm not sure if this is a problem on my end or simply a limitation of XLForm, but hopefully you can shed some light on this for me. I'll try to break it down as best I can.
I have a collection of settings with the following json structure:
"key": "hide_connections_on_profile",
"name": "Users – Hide User’s Connections list",
"description": "Profile",
"setting": true,
"category": "Privacy",
"label": "Hide my Connections list from my profile"
I go through the list and grab all the uniq categories, then map through those as the the different sections of the form. That is all working flawlessly right now.
def settings
@categories = @settings.map{ |setting| setting.category}.uniq.sort
@categories.map do |category|
@category_of_settings = @settings.select{ |user| user.category == category }
{
title: category.upcase,
cells:
@category_of_settings.map do |setting|
{
name: setting.key,
title: setting.label,
type: :check,
value: setting.setting
}
end
}
end
end
The problem is that I don't have a save button. Since I am dealing exclusively with loops here, I need to inject the save button at the end. And that's where things are not going well. First, I tried switching the first block to an each, wrapping the whole thing in [ ], with the possibility of conditionally adding a save button.
def settings
@categories = @settings.map{ |setting| setting.category}.uniq.sort
[
@categories.each do |category|
@category_of_settings = @settings.select{ |user| user.category == category }
{
title: category.upcase,
cells:
@category_of_settings.map do |setting|
{
name: setting.key,
title: setting.label,
type: :check,
value: setting.setting
}
end
}
end
]
end
It compiles just fine, but when I load that screen, I get the following error:
xl_form_patch.rb:76:in `section:': can't convert Symbol into Integer (TypeError)
I tried going back to map and then creating 2 separate methods, settings and save_button and then shoveling them together in a form_data method:
def form_data
settings << save_button
end
def settings
@categories = @settings.map{ |setting| setting.category}.uniq.sort
@categories.map do |category|
@category_of_settings = @settings.select{ |user| user.category == category }
{
title: category.upcase,
cells:
@category_of_settings.map do |setting|
{
name: setting.key,
title: setting.label,
type: :check,
value: setting.setting
}
end
}
end
end
def save_button
[{
title: nil,
cells: [{
name: :save,
title: "Save",
type: :button,
on_click: -> { save_settings }
}]
}]
end
Again, it compiles just fine, but then I get the same error:
xl_form_patch.rb:76:in `section:': can't convert Symbol into Integer (TypeError)
And at this point, I'm at a loss. Not sure if what I'm after is just not possible or if I'm missing some subtly in there somewhere.
The text was updated successfully, but these errors were encountered:
eliduke
changed the title
form_data arr
Problem shoveling a new section into form_data
Nov 29, 2015
And that seems to be working, but the returned values is only the elements from the last form section. Is it possible to include all elements from all sections in form_data?
This one is a bit of a doozy. I'm not sure if this is a problem on my end or simply a limitation of XLForm, but hopefully you can shed some light on this for me. I'll try to break it down as best I can.
I have a collection of settings with the following json structure:
I go through the list and grab all the uniq categories, then map through those as the the different sections of the form. That is all working flawlessly right now.
The problem is that I don't have a save button. Since I am dealing exclusively with loops here, I need to inject the save button at the end. And that's where things are not going well. First, I tried switching the first block to an
each
, wrapping the whole thing in[ ]
, with the possibility of conditionally adding a save button.It compiles just fine, but when I load that screen, I get the following error:
I tried going back to
map
and then creating 2 separate methods,settings
andsave_button
and then shoveling them together in aform_data
method:Again, it compiles just fine, but then I get the same error:
And at this point, I'm at a loss. Not sure if what I'm after is just not possible or if I'm missing some subtly in there somewhere.
The text was updated successfully, but these errors were encountered: