Sha256: b5f882c71c18ddd45280b8c0e3ad51698001b352721b5b72fc22d383a722ba2d

Contents?: true

Size: 1.36 KB

Versions: 10

Compression:

Stored size: 1.36 KB

Contents

<%
  # headmin/forms/checkbox
  #
  # ==== Options
  # * <tt>form<tt> - Form object
  # * <tt>attribute<tt> - Name of the attribute of the form model
  # * <tt>label<tt> - 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

10 entries across 10 versions & 1 rubygems

Version Path
headmin-0.2.9 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.8 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.7 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.6 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.5 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.4 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.3 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.2 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.1 app/views/headmin/forms/_checkbox.html.erb
headmin-0.2.0 app/views/headmin/forms/_checkbox.html.erb