Class: Decidim::Admin::FormBuilder
- Inherits:
-
FormBuilder
- Object
- FoundationRailsHelper::FormBuilder
- FormBuilder
- Decidim::Admin::FormBuilder
- Defined in:
- decidim-admin/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.
Methods inherited from FormBuilder
#areas_select, #attachment, #categories_select, #check_box, #choose_button_label, #collection_check_boxes, #collection_radio_buttons, #create_language_selector, #data_picker, #form_field_for, #hashtaggable_text_field, #label_for, #max_file_size, #password_field, #resources_select, #scopes_picker, #social_field, #text_area, #translated, #translated_one_locale, #upload, #upload_help
Methods included from Map::Autocomplete::FormBuilder
Methods included from TranslatableAttributes
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 'decidim-admin/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 'decidim-admin/lib/decidim/admin/form_builder.rb', line 65 def editor(name, = {}) super( name, { toolbar: :full, lines: 25 }.merge() ) end |