Class: CF::FormField
Instance Attribute Summary (collapse)
-
- (Object) errors
Returns the value of attribute errors.
-
- (Object) field_type
field_type for "form_field" object, e.g.
-
- (Object) form_field_params
Returns the value of attribute form_field_params.
-
- (Object) id
ID of form field.
-
- (Object) label
Label for "form_field" object, e.g.
-
- (Object) required
required boolean either true or false, e.g.
-
- (Object) station_id
station id attribute required for API Calls.
Instance Method Summary (collapse)
-
- (FormField) initialize(options = {})
constructor
Initializes a new "form_field" object
Usage of form_field.new(hash):.
Constructor Details
- (FormField) initialize(options = {})
Initializes a new "form_field" object
Usage of form_field.new(hash):
line = CF::Line.create("Digitize", "Survey") do |l|
CF::Station.create({:line => l, :type => "work"}) do |s|
CF::StandardInstruction.create({:station => s, :title => "Enter text from a business card image", :description => "Describe"}) do |i|
CF::FormField.new({:form => i, :label => "First Name", :field_type => "SA", :required => "true"})
end
end
end
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cf/form_field.rb', line 31 def initialize(={}) @form = [:form] @label = [:label] @field_type = [:field_type] @required = [:required] if !@form.nil? .delete(:form) party_param = { :body => { :api_key => CF.api_key, :form_field => } } resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@form.station.line['title'].downcase}/stations/#{@form.station.index}/form_fields.json",party_param) resp.parsed_response.each_pair do |k,v| self.send("#{k}=",v) if self.respond_to?(k) end if resp.code != 200 self.errors = resp.parsed_response['error']['message'] end self.form_field_params = @form.station.form.form_fields = self return self else @form_field_params = end end |
Instance Attribute Details
- (Object) errors
Returns the value of attribute errors
20 21 22 |
# File 'lib/cf/form_field.rb', line 20 def errors @errors end |
- (Object) field_type
field_type for "form_field" object, e.g. :field_type => "SA"
10 11 12 |
# File 'lib/cf/form_field.rb', line 10 def field_type @field_type end |
- (Object) form_field_params
Returns the value of attribute form_field_params
20 21 22 |
# File 'lib/cf/form_field.rb', line 20 def form_field_params @form_field_params end |
- (Object) id
ID of form field
16 17 18 |
# File 'lib/cf/form_field.rb', line 16 def id @id end |
- (Object) label
Label for "form_field" object, e.g. :label => "First Name"
7 8 9 |
# File 'lib/cf/form_field.rb', line 7 def label @label end |
- (Object) required
required boolean either true or false, e.g. :required => "true" & if false then you don't need to mention
13 14 15 |
# File 'lib/cf/form_field.rb', line 13 def required @required end |
- (Object) station_id
station id attribute required for API Calls
19 20 21 |
# File 'lib/cf/form_field.rb', line 19 def station_id @station_id end |