Sha256: f8b56531bd814f03ad72dc42a2e1c16f3b1f5c01ba4e7c36664007dc2b5c1879

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

<%#
    name: headmin/fields/url
    accepts block: no
    parameters:
      form: Form object
      attribute: (string) Name of the attribute of the form model
      label: (bool) Label will not be displayed if value is false
%>

<% label = local_assigns.has_key?(:label) ? label : true %>
<% disabled = local_assigns.has_key?(:disabled) ? disabled : false %>
<% required = local_assigns.has_key?(:required) ? required : false %>
<% readonly = local_assigns.has_key?(:readonly) ? readonly : false %>
<% class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false %>
<% has_list = local_assigns.has_key?(:collection) %>
<div class="<%= ('mb-3' if label) %>">
  <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label %>
  <div class="input-group">
    <span class="input-group-text"><%= bootstrap_icon('globe') %></span>
    <%= form.url_field(
          attribute,
          class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
          list: has_list ? attribute : nil,
          disabled: disabled,
          required: required,
          readonly: readonly,
          'aria-describedby': form_field_validation_id(form, attribute))
    %>
    <% if has_list %>
      <datalist id="<%= attribute %>">
        <% collection.each do |key, value| %>
          <option value="<%= value %>"><%= key %></option>
        <% end %>
      </datalist>
    <% end %>
    <%= render 'headmin/forms/fields/validation', form: form, attribute: attribute %>
  </div>
</div>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
headmin-0.1.2 app/views/headmin/forms/fields/_url.html.erb
headmin-0.1.1 app/views/headmin/forms/fields/_url.html.erb