Class: Inputs::Select::Cell
- Inherits:
-
Cell
- Object
- Cell
- Inputs::Select::Cell
- Defined in:
- app/cells/lato_core/inputs/select/cell.rb
Constant Summary collapse
- @@requested_args =
[:name]
- @@default_args =
{ value: '', label: '', placeholder: '', help: '', required: false, create: false, multiple: false, options: [], option_value: 'value', option_name: 'name', option_blank: true, class: 'md-12', attributes: {} }
Instance Method Summary collapse
-
#get_option_value_selected(option_value) ⇒ Object
This function return a string used on the HTML option to set a an option value selected or not.
-
#initialize(args = {}) ⇒ Cell
constructor
A new instance of Cell.
- #show ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Cell
Returns a new instance of Cell.
23 24 25 26 27 28 29 30 31 |
# File 'app/cells/lato_core/inputs/select/cell.rb', line 23 def initialize(args = {}) @args = validate_args( args: args, requested_args: @@requested_args, default_args: @@default_args ) set_conditions end |
Instance Method Details
#get_option_value_selected(option_value) ⇒ Object
This function return a string used on the HTML option to set a an option value selected or not.
39 40 41 42 43 44 45 46 |
# File 'app/cells/lato_core/inputs/select/cell.rb', line 39 def get_option_value_selected(option_value) if @args[:multiple] values = @args[:value].is_a?(Array) ? @args[:value] : @args[:value].split(',') return values.include?(option_value) ? "selected='selected'" : '' end @args[:value] == option_value ? "selected='selected'" : '' end |
#show ⇒ Object
33 34 35 |
# File 'app/cells/lato_core/inputs/select/cell.rb', line 33 def show render 'show.html' end |