Created
May 3, 2019 13:41
-
-
Save koss-lebedev/c841b8ddde0e6cf7c59957ad7274cb26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dynamic_attribute_inputs(form, model) | |
inputs = model.dynamic_attributes.map do |attr| | |
options = { | |
label: attr.display_name, | |
as: datatype_mapping(attr.datatype) | |
} | |
form.input attr.name, options | |
end | |
safe_join inputs | |
end | |
def datatype_mapping(type) | |
case type | |
when ActiveDynamic::DataType::Text then :text | |
when ActiveDynamic::DataType::Integer then :integer | |
else :string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment