Class: Decidim::AuthorizationFormBuilder

Inherits:
FormBuilder
  • Object
show all
Defined in:
lib/decidim/authorization_form_builder.rb

Overview

A customf orm builder to render AuthorizationHandler forms.

Instance Method Summary collapse

Methods inherited from FormBuilder

#categories_select, #editor, #translated

Instance Method Details

#all_fieldsObject

Renders all form attributes defined by the handler.

Returns a String.



10
11
12
13
14
15
16
# File 'lib/decidim/authorization_form_builder.rb', line 10

def all_fields
  fields = public_attributes.map do |name, type|
    @template.(:div, input_field(name, type), class: "field")
  end

  safe_join(fields)
end

#input(name, options = {}) ⇒ Object

Renders a single attribute from the form handlers.

name - The String name of the attribute. options - An optional Hash, accepted options are:

:as - A String name with the type the field to render
:input - An optional Hash to pass to the field method.

Returns a String.



26
27
28
29
30
31
32
33
# File 'lib/decidim/authorization_form_builder.rb', line 26

def input(name, options = {})
  if options[:as]
    send(options[:as].to_s, name, options[:input] || {})
  else
    type = find_input_type(name.to_s)
    input_field(name, type)
  end
end