Class: Forma::SelectField
- Inherits:
-
SimpleField
- Object
- Field
- SimpleField
- Forma::SelectField
- Defined in:
- lib/forma/field.rb
Overview
Selection field.
Instance Attribute Summary
Attributes inherited from Field
#actions, #after, #autofocus, #before, #child_model_name, #height, #hint, #i18n, #icon, #label, #model, #model_name, #name, #parent, #readonly, #required, #tag, #url, #value, #width
Instance Method Summary collapse
- #edit_element(val) ⇒ Object
-
#initialize(h = {}) ⇒ SelectField
constructor
A new instance of SelectField.
- #view_element(val) ⇒ Object
Methods inherited from SimpleField
Methods inherited from Field
#action, #id, #localization_key, #localized_hint, #localized_label, #name_as_chain, #parameter_name, #to_html
Methods included from Html
Methods included from Utils
extract_value, #simple_value, singular_name
Constructor Details
#initialize(h = {}) ⇒ SelectField
Returns a new instance of SelectField.
429 430 431 432 433 434 435 |
# File 'lib/forma/field.rb', line 429 def initialize(h={}) h = h.symbolize_keys @search_url = h[:search_url] @search_width = h[:search_width] || 500 @search_height = h[:search_height] || 600 super(h) end |
Instance Method Details
#edit_element(val) ⇒ Object
441 442 443 444 445 446 447 448 449 |
# File 'lib/forma/field.rb', line 441 def edit_element(val) el('div', attrs: { id: self.id, class: 'ff-select-field' }, children: [ el('input', attrs: { id: "#{self.id}_value", type: 'text', value: "#{val and val.id}" }), el('span', attrs: { id: "#{self.id}_text" }, text: val.to_s), el('a', attrs: { class: 'ff-select-link btn btn-mini', 'data-id' => self.id, 'data-url' => @search_url, 'data-width' => @search_width, 'data-height' => @search_height }, children: [ el('i', attrs: { class: 'icon icon-search' }) ]) ]) end |
#view_element(val) ⇒ Object
437 438 439 |
# File 'lib/forma/field.rb', line 437 def view_element(val) el(@tag || 'span', text: val.to_s) end |