I have some nested data:
@preset = Preset.new
I would like to have the same nested structure stored in POST params[:preset][:fields] from the submit form, so I have this in my part:
<%= text_field_tag("preset[fields][primary_category][category_id]",nil) -%>
The simple form does not know how to deal with new postgres types like hstore or json. In my case, I really do not need this to check or to determine the data type. Is there a way I can extend SimpleForm to skip the detection of column types and just output the same existing bootstrap test pattern that it prints for text fields, but for my arbitrary json nested keys?
It is possible to use this type:
<%= f.input 'preset[fields][primary_category][category_id]', :as => :json_text_field %>
Print the same as the helper above, but surrounded by a label, as well as cool div groups, etc.
I have looked at extending the base input class for documentation.
class JsonTextFieldInput < SimpleForm::Inputs::Base def input "
But this is where I got lost, because Iām not sure what to pass to @builder to bypass checking the attribute name with my own logic to display its hash keys. It also changes only the input of the form, and not the label, which also needs some modification. In any case, I could not go very far, and I could use some recommendations.
Homan source share