Sha256: f1f194e5446cc849e7a70e5f6a8cf43775cf43f33c88741f944a758c5540ddc3

Contents?: true

Size: 653 Bytes

Versions: 38

Compression:

Stored size: 653 Bytes

Contents

class BootstrapForm::FormBuilder

  def role_select(opts = {})
    collection = Chaltron.roles.map { |role| [role, I18n.translate("roles.#{role}")] }
    checked = @object.nil?? false : @object.roles
    html = inputs_collection(:roles, collection, :first, :last, checked: checked) do |name, value, options|
      options[:multiple] = true
      options[:inline] = true

      if value == opts[:disabled]
        options[:disabled] = true
        options[:checked] = true
      end
      check_box(name, options, value, nil)
    end

    hidden = opts[:disabled] || ''
    hidden_field(:roles, { value: hidden, multiple: true }).concat(html)
  end

end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
chaltron-1.1.5 lib/chaltron/bootstrap_form.rb
chaltron-1.1.4 lib/chaltron/bootstrap_form.rb
chaltron-0.3.1 lib/chaltron/bootstrap_form.rb
chaltron-1.1.3 lib/chaltron/bootstrap_form.rb
chaltron-1.1.2 lib/chaltron/bootstrap_form.rb
chaltron-1.1.1 lib/chaltron/bootstrap_form.rb
chaltron-0.3.0 lib/chaltron/bootstrap_form.rb
chaltron-1.1.0 lib/chaltron/bootstrap_form.rb
chaltron-0.2.11 lib/chaltron/bootstrap_form.rb
chaltron-1.0.10 lib/chaltron/bootstrap_form.rb
chaltron-0.2.10 lib/chaltron/bootstrap_form.rb
chaltron-1.0.9 lib/chaltron/bootstrap_form.rb
chaltron-1.0.8 lib/chaltron/bootstrap_form.rb
chaltron-1.0.7 lib/chaltron/bootstrap_form.rb
chaltron-0.2.9 lib/chaltron/bootstrap_form.rb
chaltron-1.0.6 lib/chaltron/bootstrap_form.rb
chaltron-1.0.5 lib/chaltron/bootstrap_form.rb
chaltron-1.0.4 lib/chaltron/bootstrap_form.rb
chaltron-0.2.8 lib/chaltron/bootstrap_form.rb
chaltron-0.2.7 lib/chaltron/bootstrap_form.rb