]> git.openstreetmap.org Git - rails.git/blobdiff - lib/richtext_form_builder.rb
Refactor diary entry forms to use a custom form builder
[rails.git] / lib / richtext_form_builder.rb
diff --git a/lib/richtext_form_builder.rb b/lib/richtext_form_builder.rb
new file mode 100644 (file)
index 0000000..4198f38
--- /dev/null
@@ -0,0 +1,15 @@
+class RichtextFormBuilder < BootstrapForm::FormBuilder
+  def richtext_field(attribute, options = {})
+    id = "#{@object_name}_#{attribute}"
+    type = options.delete(:format) || "markdown"
+
+    @template.render(:partial => "shared/richtext_field",
+                     :locals => { :object => @object,
+                                  :attribute => attribute,
+                                  :object_name => @object_name,
+                                  :id => id,
+                                  :type => type,
+                                  :options => options,
+                                  :builder => self })
+  end
+end