Sha256: c50e07009c25baf0220180513e9e9d5dd210476ec96a6b757b414117ad4306ee

Contents?: true

Size: 1.71 KB

Versions: 8

Compression:

Stored size: 1.71 KB

Contents

<%#
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_id = SecureRandom.uuid %>
<div class="form-group <%= form.error_class field_name %>">
  <%= form.label field_name, metadata[:label] %>
  <div class="row">
    <div class="col-6 col-sm-4">
      <div id="<%= picker_id %>" class="input-group date" data-init="datepicker" data-target-input="nearest">
        <%= form.text_field field_name, class: 'form-control datetimepicker-input', 'data-target': "##{picker_id}" %>
        <span class="input-group-append" data-target="#<%= picker_id %>" data-toggle="datetimepicker"><span class="input-group-text"><%= fa_icon 'calendar' %></span></span>
      </div>
    </div>
  </div>
  <%= form.error_messages field_name %>
  <%= hint_of metadata %>
</div>

<% unless @datepicker_init %>
  <% @datepicker_init = true %>
  <% content_for :custom_javascript do %>
    <% javascript_tag do %>
      jQuery(document).off(readyPrefix('.date')).on(readyPrefix('.date'), function () {
        $('[data-init="datepicker"]').each(function() {
          var $input = $('input', this),
            val = ($input.attr('value') || '').split(' ').slice(0,1).join(' ');
          $input.val(moment(val).format('YYYY-MM-DD'));
          $(this).datetimepicker({
            format: 'YYYY-MM-DD'
          });
        })
      })
    <% end %>
  <% end %>
<% end %>

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wallaby-6.1.6 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.1.5 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.1.4 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.1.3 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.1.2 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.1.1 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.1.0 app/views/wallaby/resources/form/_date.html.erb
wallaby-6.0.2 app/views/wallaby/resources/form/_date.html.erb