Sha256: e443f0178d4c007a89f953d1ec2a82412753184bd74f3a8bf3cc27b04889e71d

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

<%
  # headmin/forms/checkbox
  #
  # ==== Options
  # * +form+ - Form object
  # * +attribute+ - Name of the attribute of the form model
  # * +label+ - Text to show as label. Label will be hidden if value is false
  #
  # ==== Examples
  #   Basic version
  #   <%= render 'headmin/forms/image', form: form, attribute: :image %#>

  class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
  data = local_assigns.has_key?(:data) ? data : nil
  disabled = local_assigns.has_key?(:disabled) ? disabled : false
  label = local_assigns.has_key?(:label) ? label : nil
  readonly = local_assigns.has_key?(:readonly) ? readonly : false
  required = local_assigns.has_key?(:required) ? required : false

  options = {
    'aria-describedby': form_field_validation_id(form, attribute),
    class: "form-checkbox-input #{form_field_validation_class(form, attribute)} #{class_names}",
    data: data,
    disabled: disabled,
    placeholder: attribute,
    readonly: readonly,
    required: required,
  }

  show_label = label != false
%>

<div class="<%= ('mb-3 text-start' if show_label) %>">
  <%= form.check_box(attribute, options) %>
  <% if show_label %>
    <%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
  <% end %>
  <%= render 'headmin/forms/validation', form: form, attribute: attribute %>
</div>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
headmin-0.3.2 app/views/headmin/forms/_checkbox.html.erb
headmin-0.3.1 app/views/headmin/forms/_checkbox.html.erb