Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/nacho/form_builder.rb

Instance Method Summary collapse

Instance Method Details

#nacho_select(method, choices = nil, options = {}, html_options = {}) ⇒ Object

The helper for a FormBuilder class. Will create the select and the needed modal that contains the given form for the target model to create.

A multiple select will generate a button to trigger the modal.

Parameters:

Options Hash (options):

  • :include_blank (Boolean)

    Include a blank option (Forced to true when choices.count == 0)

  • :new_option_text (String)

    Text to display as the option that will trigger the new modal (Default “– Add new –”, will be ignored if html_options[:multiple] is set to true)

  • :value_key (Symbol)

    The attribute of the model that will be used as the option value from the JSON return when a new record is created

  • :text_key (Symbol)

    The attribute of the model that will be used as the option display content from the JSON return when a new record is created

  • :new_key (Symbol)

    The JSON key that will contain the value of the record that was created with the modal

  • :modal_title (String)

    The title of the modal (Default to “Add new <model.class.name>”)

  • :partial (String)

    The form partial for the modal body



56
57
58
# File 'lib/nacho/form_builder.rb', line 56

def nacho_select(method, choices = nil, options = {}, html_options = {})
  @template.nacho_select(@object_name, method, choices, objectify_options(options), objectify_options(html_options))
end