Module: Wallaby::FormHelper
- Included in:
- ResourcesHelper
- Defined in:
- lib/helpers/wallaby/form_helper.rb
Overview
Form helper
Instance Method Summary collapse
- #form_type_partial_render(options = {}, locals = {}, &block) ⇒ Object
-
#polymorphic_options(metadata, wildcard = 'QUERY', select_options = {}) ⇒ String
To generate dropdown options (class => url) for polymorphic class.
-
#remote_url(url, model_class, wildcard = 'QUERY') ⇒ Object
To generate remote url for auto select plugin.
Instance Method Details
#form_type_partial_render(options = {}, locals = {}, &block) ⇒ Object
6 7 8 |
# File 'lib/helpers/wallaby/form_helper.rb', line 6 def form_type_partial_render( = {}, locals = {}, &block) PartialRenderer.render_form self, , locals, &block end |
#polymorphic_options(metadata, wildcard = 'QUERY', select_options = {}) ⇒ String
To generate dropdown options (class => url) for polymorphic class. This function will pull out remote urls from ‘metadata` (Class => url).
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/helpers/wallaby/form_helper.rb', line 34 def (, wildcard = 'QUERY', = {}) urls = [:remote_urls] || {} = ([:polymorphic_list] || []).map do |klass| [ klass, klass, { data: { url: remote_url(urls[klass], klass, wildcard) } } ] end , end |
#remote_url(url, model_class, wildcard = 'QUERY') ⇒ Object
To generate remote url for auto select plugin.
17 18 19 20 21 22 23 24 |
# File 'lib/helpers/wallaby/form_helper.rb', line 17 def remote_url(url, model_class, wildcard = 'QUERY') url || index_path( model_class, url_params: { q: wildcard, per: Wallaby.configuration.pagination.page_size } ) end |