lib/compony/model_fields/anchormodel.rb in compony-0.0.4 vs lib/compony/model_fields/anchormodel.rb in compony-0.0.5

- old
+ new

@@ -21,8 +21,15 @@ selected: selected_cst&.key || anchormodel_class.all.first, include_blank: anchormodel_attribute.optional }.merge(input_opts) return form.input @name, **opts end + + def simpleform_input_hidden(form, _component, **input_opts) + selected_cst = form.object.send(@name) + input_opts[:input_html] ||= {} + input_opts[:input_html][:value] = selected_cst.is_a?(::Anchormodel) ? selected_cst.key : selected_cst + return form.input @name, as: :hidden, **input_opts + end end end end