Sha256: 8c9f8eade0b40b1315ca466b92b11208a457d0d832f577aa6a766d9b80ac493d

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

<div class="field-unit__label">
  <%= f.label field.attribute %>
</div>
<div class="field-unit__field">
  <%= f.text_field(
    field.attribute,
    value: field.pretty,
    )
  %>
<script>
  (function() {
    var inputs = document.querySelectorAll('input')
    var input = inputs[inputs.length - 1]

    document.addEventListener("DOMContentLoaded", function(evt) {

      var $f = $(input).parents('form');
      $f.on('submit', function() {
        var unixtime_val = Date.parse( $(input).val() ) / 1000;

        $('<input>').attr({
          type: 'hidden',
          name: $(input).attr('name'),
          value: isNaN(unixtime_val) ? null : unixtime_val,
        }).appendTo($f);

        $(input).attr('name', null);
      });
    })
  })()
</script>
</div>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
administrate-field-unixtime-0.0.3 app/views/fields/unixtime/_form.html.erb
administrate-field-unixtime-0.0.2 app/views/fields/unixtime/_form.html.erb
administrate-field-unixtime-0.0.1 app/views/fields/unixtime/_form.html.erb