Class: ComfyPress::FormBuilder
- Inherits:
-
FormattedForm::FormBuilder
- Object
- FormattedForm::FormBuilder
- ComfyPress::FormBuilder
- Defined in:
- lib/comfypress/form_builder.rb
Instance Method Summary collapse
- #collection(tag, index) ⇒ Object
-
#default_tag_field(tag, index, method = :text_field_tag, options = {}) ⇒ Object
– Tag Field Fields —————————————————–.
- #field_date_time(tag, index) ⇒ Object
- #field_integer(tag, index) ⇒ Object
- #field_rich_text(tag, index) ⇒ Object
- #field_string(tag, index) ⇒ Object
- #field_text(tag, index) ⇒ Object
- #page_date_time(tag, index) ⇒ Object
- #page_file(tag, index) ⇒ Object
- #page_files(tag, index) ⇒ Object
- #page_integer(tag, index) ⇒ Object
- #page_markdown(tag, index) ⇒ Object
- #page_rich_text(tag, index) ⇒ Object
- #page_string(tag, index) ⇒ Object
- #page_text(tag, index) ⇒ Object
Instance Method Details
#collection(tag, index) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/comfypress/form_builder.rb', line 82 def collection(tag, index) = [["---- Select #{tag.collection_class.titleize} ----", nil]] + tag.collection_objects.collect do |m| [m.send(tag.collection_title), m.send(tag.collection_identifier)] end content = @template.select_tag( "page[blocks_attributes][#{index}][content]", @template.(, :selected => tag.content), :id => nil ) content << @template.hidden_field_tag("page[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil) element(tag.identifier.titleize, content, :class => tag.class.to_s.demodulize.underscore ) end |
#default_tag_field(tag, index, method = :text_field_tag, options = {}) ⇒ Object
– Tag Field Fields —————————————————–
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/comfypress/form_builder.rb', line 4 def default_tag_field(tag, index, method = :text_field_tag, = {}) label = tag.page.class.human_attribute_name(tag.identifier.to_s) css_class = tag.class.to_s.demodulize.underscore content = '' case method when :file_field_tag input_params = {:id => nil} name = "page[blocks_attributes][#{index}][content]" if .delete(:multiple) input_params.merge!(:multiple => true) name << '[]' end content << @template.send(method, name, input_params) content << @template.render(:partial => 'cms_admin/files/page_form', :object => tag.block) else content << @template.send(method, "page[blocks_attributes][#{index}][content]", tag.content, ) end content << @template.hidden_field_tag("page[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil) element(label, content.html_safe) end |
#field_date_time(tag, index) ⇒ Object
30 31 32 |
# File 'lib/comfypress/form_builder.rb', line 30 def field_date_time(tag, index) default_tag_field(tag, index, :text_field_tag, :data => {:datetime => true}) end |
#field_integer(tag, index) ⇒ Object
34 35 36 |
# File 'lib/comfypress/form_builder.rb', line 34 def field_integer(tag, index) default_tag_field(tag, index, :number_field_tag) end |
#field_rich_text(tag, index) ⇒ Object
46 47 48 |
# File 'lib/comfypress/form_builder.rb', line 46 def field_rich_text(tag, index) default_tag_field(tag, index, :text_area_tag, :data => {:rich_text => true}) end |
#field_string(tag, index) ⇒ Object
38 39 40 |
# File 'lib/comfypress/form_builder.rb', line 38 def field_string(tag, index) default_tag_field(tag, index) end |
#field_text(tag, index) ⇒ Object
42 43 44 |
# File 'lib/comfypress/form_builder.rb', line 42 def field_text(tag, index) default_tag_field(tag, index, :text_area_tag, :data => {:cm_mode => 'text/html'}) end |
#page_date_time(tag, index) ⇒ Object
50 51 52 |
# File 'lib/comfypress/form_builder.rb', line 50 def page_date_time(tag, index) default_tag_field(tag, index, :text_field_tag, :data => {:datetime => true}) end |
#page_file(tag, index) ⇒ Object
70 71 72 |
# File 'lib/comfypress/form_builder.rb', line 70 def page_file(tag, index) default_tag_field(tag, index, :file_field_tag) end |
#page_files(tag, index) ⇒ Object
74 75 76 |
# File 'lib/comfypress/form_builder.rb', line 74 def page_files(tag, index) default_tag_field(tag, index, :file_field_tag, :multiple => true) end |
#page_integer(tag, index) ⇒ Object
54 55 56 |
# File 'lib/comfypress/form_builder.rb', line 54 def page_integer(tag, index) default_tag_field(tag, index, :number_field_tag) end |
#page_markdown(tag, index) ⇒ Object
78 79 80 |
# File 'lib/comfypress/form_builder.rb', line 78 def page_markdown(tag, index) default_tag_field(tag, index, :text_area_tag, :data => {:cm_mode => 'text/x-markdown'}) end |
#page_rich_text(tag, index) ⇒ Object
66 67 68 |
# File 'lib/comfypress/form_builder.rb', line 66 def page_rich_text(tag, index) default_tag_field(tag, index, :text_area_tag, :data => {:rich_text => true}) end |
#page_string(tag, index) ⇒ Object
58 59 60 |
# File 'lib/comfypress/form_builder.rb', line 58 def page_string(tag, index) default_tag_field(tag, index) end |
#page_text(tag, index) ⇒ Object
62 63 64 |
# File 'lib/comfypress/form_builder.rb', line 62 def page_text(tag, index) default_tag_field(tag, index, :text_area_tag, :data => {:cm_mode => 'text/html'}) end |