<%# The following params are the variables that can be used in this partial. @param form [Wallaby::FormBuilder] custom form object that adds a few helper methods and delegate missing methods to the view @param object [Wallaby::ResourceDecorator] decorator instance which wraps the resource (e.g. ActiveRecord) instance @param field_name [String] name of the field @param value [Object] value of the field @param metadata [Hash] metadata of the field %> <% picker_id1 = SecureRandom.uuid %> <% picker_id2 = SecureRandom.uuid %>
<%= form.label field_name, metadata[:label] %>
F <%= form.text_field field_name, value: value.try(:first), multiple: true, class: 'form-control datetimepicker-input', 'data-target': "##{picker_id1}" %> <%= fa_icon 'calendar' %>
T <%= form.text_field field_name, value: value.try(:last), multiple: true, class: 'form-control datetimepicker-input', 'data-target': "##{picker_id2}" %> <%= fa_icon 'calendar' %>
<%= form.error_messages field_name %> <%= hint_of metadata %>
<% unless @datetimepicker_init %> <% @datetimepicker_init = true %> <% content_for :custom_javascript do %> <% javascript_tag do %> jQuery(document).off(readyPrefix('.tstzrange')).on(readyPrefix('.tstzrange'), function () { $('[data-init="datetimepicker"]').each(function() { var $input = $('input', this), val = ($input.attr('value') || '').split(' ').slice(0,2).join(' '); $input.val(moment(val).format('YYYY-MM-DD HH:mm')); $(this).datetimepicker({ format: 'YYYY-MM-DD HH:mm', sideBySide: true }); }) }) <% end %> <% end %> <% end %>