Changes in the form are not saved to database

后端 未结 4 1342
轻奢々
轻奢々 2020-12-08 03:16

I\'m trying to add a date field to my form.

I added bootstrap-datepicker-rails gem, all required css and javascript.

When I choose the date in the calendar a

4条回答
  •  佛祖请我去吃肉
    2020-12-08 03:52

    Andrew Hacking's answer worked great for me, with two small changes to app/inputs/bootstrap_datepicker_input.rb. I'm using Rails 4.2.0. It was ignoring the value in the hidden field as a duplicate (since the text input and hidden input have identical "name" attributes). I switched:

    "#{@builder.text_field(attribute_name, text_field_options.to_hash)}\n"
    

    ... to this:

    "#{@builder.text_field(attribute_name.to_s+'_box',text_field_options.to_hash)}\n" +
    

    Also, I was losing wrapper options, so I added an argument to input and merged the wrapper options into the html options.

    This:

    def input
        text_field_options = input_html_options.with_indifferent_access
        ...
    

    ... became:

    def input(wrapper_options)
        merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
        text_field_options = merged_input_options.with_indifferent_access
        ...
    

提交回复
热议问题