Class: Fe::TextField

Inherits:
Question show all
Defined in:
app/models/fe/text_field.rb

Instance Attribute Summary

Attributes inherited from Question

#answers

Attributes inherited from Element

#old_id

Instance Method Summary collapse

Methods inherited from Question

#check_answer_sheet_matches_set_response_answer_sheet, #default_label?, #delete_file, #display_response, #has_response?, #locked?, #response, #responses, #save_file, #save_response, #set_response

Methods inherited from Element

#all_elements, #conditional_answers, #conditional_match, #content, create_from_import, #css_classes, #duplicate, #export_hash, #export_to_yaml, #has_response?, #hidden?, #hidden_by_choice_field?, #hidden_by_conditional?, #label, #limit, #matches_filter, max_label_length, #page_id, #pages_on, #position, #previous_element, #question?, #required?, #reuseable?, #set_conditional_element, #set_position, #tooltip, #update_any_previous_conditional_elements, #update_page_all_element_ids, #visibility_affecting_element_ids, #visibility_affecting_questions, #visible?

Instance Method Details

#ptemplateObject

which view to render this element?



8
9
10
11
12
13
14
# File 'app/models/fe/text_field.rb', line 8

def ptemplate
  if self.style == 'essay'
    'fe/text_area_field'
  else
    'fe/text_field'
  end
end

#validation_class(answer_sheet, page = nil) ⇒ Object

css class names for javascript-based validation



17
18
19
20
21
22
23
24
25
26
# File 'app/models/fe/text_field.rb', line 17

def validation_class(answer_sheet, page = nil)
  validation = ''
  validation += ' required' if self.required?(answer_sheet, page)
  # validate-number, etc.
  validate_style = ['number', 'currency-dollar', 'email', 'url', 'phone'].find {|v| v == self.style }
  if validate_style
    validation += ' validate-' + validate_style
  end
  validation
end