Class: FormBuilder
- Inherits:
-
Object
- Object
- FormBuilder
- Defined in:
- lib/form_builder.rb
Overview
Create custom forms for complete text data extraction stage
Defined Under Namespace
Classes: Field
Instance Method Summary collapse
- #add_javascript(js) ⇒ Object
- #each_field ⇒ Object
-
#initialize(sr, cd, user) ⇒ FormBuilder
constructor
A new instance of FormBuilder.
- #javascript ⇒ Object
Constructor Details
#initialize(sr, cd, user) ⇒ FormBuilder
Returns a new instance of FormBuilder.
34 35 36 37 38 39 |
# File 'lib/form_builder.rb', line 34 def initialize(sr, cd,user) @sr=sr @cd=cd @user=user @javascript=[] end |
Instance Method Details
#add_javascript(js) ⇒ Object
45 46 47 |
# File 'lib/form_builder.rb', line 45 def add_javascript(js) @javascript.push(js) end |
#each_field ⇒ Object
40 41 42 43 44 |
# File 'lib/form_builder.rb', line 40 def each_field SrField.where(:systematic_review_id=>@sr[:id]).order(:order).each do |field| yield Field.new(field, @sr,@cd, @user,self) end end |
#javascript ⇒ Object
48 49 50 51 52 53 |
# File 'lib/form_builder.rb', line 48 def javascript return "" unless @javascript.length>0 "<script type='text/javascript'> #{@javascript.join("\n")} </script>" end |