Class: Decidim::CustomUserFields::Fields::TextField

Inherits:
GenericField
  • Object
show all
Defined in:
lib/decidim/custom_user_fields/fields/text_field.rb

Instance Attribute Summary

Attributes inherited from GenericField

#definition, #options

Instance Method Summary collapse

Methods inherited from GenericField

#class_name, #initialize, #required?

Constructor Details

This class inherits a constructor from Decidim::CustomUserFields::Fields::GenericField

Instance Method Details

#configure_form(form) ⇒ Object



5
6
7
8
# File 'lib/decidim/custom_user_fields/fields/text_field.rb', line 5

def configure_form(form)
  form.attribute(name, String)
  form.validates(name, presence: required?)
end

#form_tag(form_tag) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/decidim/custom_user_fields/fields/text_field.rb', line 14

def form_tag(form_tag)
  (
    :div,
    form_tag.text_field(name),
    class: class_name
  )
end

#map_model(form, data) ⇒ Object



10
11
12
# File 'lib/decidim/custom_user_fields/fields/text_field.rb', line 10

def map_model(form, data)
  form[name] = data[name] if data[name].present?
end