Sha256: 921505edbe954305dcdf08e9ed19ff2c4e71f4b46b3524d45c7437e53ba1c65c

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

<%
  # name: headmin/forms/label
  #
  # ==== Required parameters
  # * +form+ - Form object
  # * +attribute+ - Name of the attribute of the form model
  #
  # ==== Options
  # * +class+ - Optional HTML class attribute
  # * +for+ - Set reference to the input id
  # * +required+ - Set to true if you want to highlight the requirement
  # * +text+ - Custom label to be used instead of the attribute
  #
  # ==== References
  # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
  # https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormHelper/label
  #
  # ==== Examples
  #   Basic version
  #   <%= render 'headmin/forms/label', form: form, attribute: :image %#>

  text = local_assigns[:text]
  default_options = {
    class: ['form-label', local_assigns[:class]].join(' '),
    form: form.options[:id],
  }
  options = default_options.merge(local_assigns.slice(*%i(for required)).compact)
%>

<%= form.label attribute, text, options %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
headmin-0.3.4 app/views/headmin/forms/_label.html.erb
headmin-0.3.3 app/views/headmin/forms/_label.html.erb
headmin-0.3.2 app/views/headmin/forms/_label.html.erb
headmin-0.3.1 app/views/headmin/forms/_label.html.erb