Class: FormtasticExtensions::SemanticFormBuilder
- Inherits:
-
Formtastic::SemanticFormBuilder
- Object
- Formtastic::SemanticFormBuilder
- FormtasticExtensions::SemanticFormBuilder
- Defined in:
- lib/formtastic_extensions/semantic_form_builder.rb
Constant Summary collapse
- @@input_class =
'b_field'
- @@inputs_class =
'b_fields_set'
'b_buttons_set'
Instance Method Summary collapse
- #buttons(*args, &block) ⇒ Object
- #input(method, options = {}) ⇒ Object
- #inputs(*args, &block) ⇒ Object
- #wysiwyg_input(method, options = {}) ⇒ Object
Instance Method Details
#buttons(*args, &block) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/formtastic_extensions/semantic_form_builder.rb', line 61 def (*args, &block) = args. [:class] ||= @@buttons_class if block_given? field_set_and_list_wrapping(, &block) else args = [:commit] if args.empty? contents = args.map { || send(:"#{}_button") } field_set_and_list_wrapping(, contents) end end |
#input(method, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/formtastic_extensions/semantic_form_builder.rb', line 13 def input(method, = {}) [:required] = method_required?(method) unless .key?(:required) [:as] ||= default_input_type(method) html_class = [ [:as], ([:required] ? :required : :optional) ] html_class << 'error' if @object && @object.respond_to?(:errors) && !@object.errors[method.to_sym].blank? html_class << method.to_s wrapper_html = .delete(:wrapper_html) || {} wrapper_html[:id] ||= generate_html_id(method) wrapper_html[:class] = class_with_modifiers(@@input_class, html_class << wrapper_html[:class]) if [:input_html] && [:input_html][:id] [:label_html] ||= {} [:label_html][:for] ||= [:input_html][:id] end input_parts = @@inline_order.dup input_parts.delete(:errors) if [:as] == :hidden list_item_content = input_parts.map do |type| send(:"inline_#{type}_for", method, ) end.compact.join("\n") return template.content_tag(:li, list_item_content, wrapper_html) end |
#inputs(*args, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/formtastic_extensions/semantic_form_builder.rb', line 40 def inputs(*args, &block) = args. [:class] ||= @@inputs_class if [:for] inputs_for_nested_attributes(args, , &block) elsif block_given? field_set_and_list_wrapping(, &block) else if @object && args.empty? args = @object.class.reflections.map { |n,_| n if _.macro == :belongs_to } args += @object.class.content_columns.map(&:name) args -= %w[created_at updated_at created_on updated_on lock_version version] args.compact! end contents = args.map { |method| input(method.to_sym) } field_set_and_list_wrapping(, contents) end end |
#wysiwyg_input(method, options = {}) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/formtastic_extensions/semantic_form_builder.rb', line 74 def wysiwyg_input(method, = {}) = .delete(:input_html) || {} [:class] ||= '' [:class] << ' mceEditor' self.label(method, ()) + self.text_area(method, ) end |