Class: Basepack::Forms::Edit
- Extended by:
- RailsAdmin::I18nSupport
- Defined in:
- lib/basepack/forms/edit.rb
Instance Attribute Summary collapse
-
#builder_default_options ⇒ Object
Returns the value of attribute builder_default_options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#simple_form ⇒ Object
readonly
Returns the value of attribute simple_form.
Attributes inherited from Base
#association_chain, #factory, #groups, #nested_in, #partial, #resource, #resource_class, #view
Class Method Summary collapse
Instance Method Summary collapse
- #builder ⇒ Object
- #default_partial ⇒ Object
-
#initialize(factory, chain, options = {}) ⇒ Edit
constructor
A new instance of Edit.
- #render_field!(field) ⇒ Object
- #textfield_options(field) ⇒ Object
- #with_simple_form(simple_form, &block) ⇒ Object
Methods inherited from Base
#build_from_factory, #chain, #chain_with_class, #configure, #content_for_field, #default_group, #field, #field_names, #fields, #fields_hash, #group, #has_field?, #hide_field, #hide_fields, #inspect, #inverse_of_nested_in?, #label, #label_plural, #new_form, #new_record?, #permit_params, #render_field, #sanitize_params, #show_fields, #show_only_fields, #translate, #visible_field, #visible_fields, #visible_groups, #with_resource
Constructor Details
#initialize(factory, chain, options = {}) ⇒ Edit
Returns a new instance of Edit.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/basepack/forms/edit.rb', line 29 def initialize(factory, chain, = {}) super @path = [:path] @builder_default_options = { html: { multipart: true, class: 'form-horizontal denser' }, defaults: { input_html: { class: 'span6'} } } if [:method].present? @builder_default_options[:method] = [:method] end end |
Instance Attribute Details
#builder_default_options ⇒ Object
Returns the value of attribute builder_default_options.
26 27 28 |
# File 'lib/basepack/forms/edit.rb', line 26 def @builder_default_options end |
#path ⇒ Object
Returns the value of attribute path.
27 28 29 |
# File 'lib/basepack/forms/edit.rb', line 27 def path @path end |
#simple_form ⇒ Object (readonly)
Returns the value of attribute simple_form.
25 26 27 |
# File 'lib/basepack/forms/edit.rb', line 25 def simple_form @simple_form end |
Class Method Details
.data_picker_options ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/basepack/forms/edit.rb', line 9 def { dateFormat: date_format, # TODO - without %d -> dd, ... dayNames: day_names, dayNamesShort: abbr_day_names, dayNamesMin: abbr_day_names, firstDay: "1", monthNames: month_names, monthNamesShort: abbr_month_names, } end |
Instance Method Details
#builder ⇒ Object
50 51 52 |
# File 'lib/basepack/forms/edit.rb', line 50 def builder simple_form end |
#default_partial ⇒ Object
46 47 48 |
# File 'lib/basepack/forms/edit.rb', line 46 def default_partial 'forms/edit' end |
#render_field!(field) ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/basepack/forms/edit.rb', line 155 def render_field!(field) if field.read_only? simple_form.input field.name, label: field.label, hint: field.help, required: field.required? do field.pretty_value end else view.render field.partial, form: self, field: field end end |
#textfield_options(field) ⇒ Object
141 142 143 144 145 |
# File 'lib/basepack/forms/edit.rb', line 141 def (field) = (field.html_attributes || {}).dup .reverse_merge!(@builder_default_options[:defaults][:input_html]) if @builder_default_options[:defaults] end |
#with_simple_form(simple_form, &block) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/basepack/forms/edit.rb', line 54 def with_simple_form(simple_form, &block) @simple_form = simple_form begin yield(self) ensure @simple_form = nil end end |