Class: Decidim::Admin::FormBuilder
- Inherits:
-
FormBuilder
- Object
- FormBuilder
- Decidim::Admin::FormBuilder
- Defined in:
- lib/decidim/admin/form_builder.rb
Overview
This custom FormBuilder extends the FormBuilder present in core with fields only used in admin.
Direct Known Subclasses
Instance Method Summary collapse
-
#autocomplete_select(attribute, selected = nil, options = {}, prompt_options = {}) {|resource| ... } ⇒ String
Generates a select field with autocompletion using ajax.
-
#editor(name, options = {}) ⇒ Object
Calls Decidim::FormBuilder#editor with default options for admin.
Instance Method Details
#autocomplete_select(attribute, selected = nil, options = {}, prompt_options = {}) {|resource| ... } ⇒ String
Generates a select field with autocompletion using ajax
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/decidim/admin/form_builder.rb', line 42 def autocomplete_select(attribute, selected = nil, = {}, = {}) selected = yield(selected) if selected template = "" template += label(attribute, ([:label] || label_for(attribute)) + required_for_attribute(attribute)) unless [:label] == false template += content_tag(:div, nil, class: [:class], data: { autocomplete: { name: [:name] || "#{@object_name}[#{attribute}]", options: ([:default_options].to_a + [selected]).compact, placeholder: [:placeholder], searchURL: [:url], changeURL: [:change_url], selected: selected ? selected[:value] : "", searchPromptText: [:search_prompt] || I18n.t("autocomplete.search_prompt", scope: "decidim.admin"), noResultsText: [:no_results] || I18n.t("autocomplete.no_results", scope: "decidim.admin") }, autocomplete_for: attribute, plugin: "autocomplete" }) template += error_for(attribute, ) if error?(attribute) template.html_safe end |
#editor(name, options = {}) ⇒ Object
Calls Decidim::FormBuilder#editor with default options for admin.
65 66 67 68 69 70 71 72 73 |
# File 'lib/decidim/admin/form_builder.rb', line 65 def editor(name, = {}) super( name, { toolbar: :full, lines: 25 }.merge() ) end |