Sha256: f0c47443cfed6d4d70695e758ca3e704438e652c19d9b0cbcc323b41130fea70

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 KB

Contents

<%#
    name: headmin/fields/text
    accepts block: no
    parameters:
      form: Form object
      attribute: (string) Name of the attribute of the form model
      label: (bool | string) Label will not be displayed if value is false or accepts a string 'float' to get a "floating label"
%>

<% label = local_assigns.has_key?(:label) ? label : true %>
<% float_label = label == :float %>
<% 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="<%= 'form-floating' if float_label %> <%= ('mb-3 text-start' if label) %> ">
  <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label && !float_label %>
  <%= form.email_field(
        attribute,
        class: "form-control #{form_field_validation_class(form, attribute)} #{class_names}",
        list: has_list ? attribute : nil,
        disabled: disabled,
        placeholder: attribute,
        required: required,
        readonly: readonly,
        'aria-describedby': form_field_validation_id(form, attribute)
      )
  %>
  <%= render 'headmin/forms/fields/label', form: form, attribute: attribute, required: required if label && float_label %>
  <% 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>

Version data entries

2 entries across 2 versions & 1 rubygems

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