简体   繁体   中英

Is there a way to prevent Formtastic from overriding “type” parameter?

I am using a jquery plugin for a datetime picker, and it requires the type parameter to be set to 'text'.

So I tried the normal method:

= semantic_form_for @schedule do |f|
  = f.input :start_at, :as => :datetime_picker, :input_html => { :class=> 'datetimepicker', :type => 'text' }

But Formtastic is overriding that type and setting it to datetime-local.

<input id="datetimepicker" maxlength="16" name="schedule[start_at]" size="16" step="1" type="datetime-local">

Is there a way to negate Formtastic automatically setting the type, without changing the gem?

So, I realised that I was heading down the wrong path and that if I wanted it be of the text type, it should be a string or text input. Which went against my original thinking that if I want a datetime picker, I should tell formtastic, when I should have only been telling the jquery plugin.

Here is what my haml looks like now:

= semantic_form_for @schedule do |f|
  = f.input :start_at, :as => :string, :input_html => { :class => 'datetimepicker', :type => 'text' }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM