Module: RightRails::Helpers::Forms

Defined in:
lib/right_rails/helpers/forms.rb

Overview

RightJS specific form features module

Defined Under Namespace

Modules: FormBuilderMethods, InstanceTagMethods, Util

Instance Method Summary collapse

Instance Method Details

#autocomplete_field(object_name, method, options) ⇒ Object Also known as: autocompleter_field

The form_for level autocomplete-field generator



38
39
40
41
42
43
44
# File 'lib/right_rails/helpers/forms.rb', line 38

def autocomplete_field(object_name, method, options)
  options = Util.autocompleter_options(self, options)

  tag = ActionView::Helpers::InstanceTag.new(
    object_name, method, self, options.delete(:object))
  tag.to_autocomplete_field_tag(options)
end

#autocomplete_field_tag(name, value, options) ⇒ Object Also known as: autocompleter_field_tag

Autocompletion field tag

The options should contain an url or a list of local options



31
32
33
# File 'lib/right_rails/helpers/forms.rb', line 31

def autocomplete_field_tag(name, value, options)
  text_field_tag name, value, Util.autocompleter_options(self, options)
end

#calendar_field(object_name, method, options = {}) ⇒ Object

The form_for level calendar field generator



18
19
20
21
22
23
24
# File 'lib/right_rails/helpers/forms.rb', line 18

def calendar_field(object_name, method, options={})
  options = Util.calendar_options(self, options)

  tag = ActionView::Helpers::InstanceTag.new(
    object_name, method, self, options.delete(:object))
  tag.to_calendar_field_tag(options)
end

#calendar_field_tag(name, value = nil, options = {}) ⇒ Object

Generates the calendar field tag

The options might contain the usual html options along with the RightJS Calendar options



11
12
13
# File 'lib/right_rails/helpers/forms.rb', line 11

def calendar_field_tag(name, value=nil, options={})
  text_field_tag name, value, Util.calendar_options(self, options)
end

#colorpicker_field(object_name, method, options = {}) ⇒ Object

A colorpicker field for a form



107
108
109
110
111
112
113
# File 'lib/right_rails/helpers/forms.rb', line 107

def colorpicker_field(object_name, method, options={})
  options = Util.colorpicker_options(self, options)

  ActionView::Helpers::InstanceTag.new(
    object_name, method, self, options.delete(:object)
  ).to_colorpicker_field_tag(options)
end

#colorpicker_field_tag(name, value, options = {}) ⇒ Object

a standalone colorpicker field tag



100
101
102
# File 'lib/right_rails/helpers/forms.rb', line 100

def colorpicker_field_tag(name, value, options={})
  text_field_tag name, value, Util.colorpicker_options(self, options)
end

#rater(object_name, method, options = {}) ⇒ Object

The form level rater generator



78
79
80
81
82
83
# File 'lib/right_rails/helpers/forms.rb', line 78

def rater(object_name, method, options={})
  object = options.delete(:object)
  ActionView::Helpers::InstanceTag.new(object_name, method, self, object
    ).to_rater_tag(Util.rater_options(self, options)) +
    "\n" + Util.rater_generator(self, object_name, nil, options, method)
end

#rater_display(value, options = {}) ⇒ Object

Builds a dummy rater, just for displaying purposes



88
89
90
91
92
93
94
95
# File 'lib/right_rails/helpers/forms.rb', line 88

def rater_display(value, options={})
  rightjs_require_module 'rater'

   :div, RightRails::Helpers.html_safe((0...(options[:size] || 5)).to_a.collect{ |i|
     :div, RightRails::Helpers.html_safe('★'),
      :class => i < value ? RightRails::Config.rightjs_version < 2 ? "right-rater-glow" : "active" : nil
  }.join('')), :class => "#{RightRails::Helpers.css_prefix}-rater #{RightRails::Helpers.css_prefix}-rater-disabled"
end

#rater_tag(name, value, options = {}) ⇒ Object

The rater widget basic generator



70
71
72
73
# File 'lib/right_rails/helpers/forms.rb', line 70

def rater_tag(name, value, options={})
  hidden_field_tag(name, value, Util.rater_options(self, options)) +
    "\n" + Util.rater_generator(self, name, value, options)
end

#rte_field(object_name, method, options = {}) ⇒ Object

a rte-field for a form



143
144
145
146
147
148
149
# File 'lib/right_rails/helpers/forms.rb', line 143

def rte_field(object_name, method, options={})
  options = Util.rte_options(self, options)

  ActionView::Helpers::InstanceTag.new(
    object_name, method, self, options.delete(:object)
  ).to_rte_field_tag(options)
end

#rte_field_tag(name, value, options = {}) ⇒ Object

a standalone RTE field tag



136
137
138
# File 'lib/right_rails/helpers/forms.rb', line 136

def rte_field_tag(name, value, options={})
  text_area_tag name, value, Util.rte_options(self, options)
end

#slider(object_name, method, options = {}) ⇒ Object

The form_for level slider widget generator



60
61
62
63
64
65
# File 'lib/right_rails/helpers/forms.rb', line 60

def slider(object_name, method, options={})
  object = options.delete(:object)
  ActionView::Helpers::InstanceTag.new(object_name, method, self, object
    ).to_slider_tag(Util.slider_options(self, options)) + "\n" +
    Util.slider_generator(self, object_name, nil, options, method)
end

#slider_tag(name, value, options = {}) ⇒ Object

The slider widget generator



52
53
54
55
# File 'lib/right_rails/helpers/forms.rb', line 52

def slider_tag(name, value, options={})
  hidden_field_tag(name, value, Util.slider_options(self, options)) +
    "\n" + Util.slider_generator(self, name, value, options)
end

#tags_field(object_name, method, options = {}) ⇒ Object

a tags-field for a form



125
126
127
128
129
130
131
# File 'lib/right_rails/helpers/forms.rb', line 125

def tags_field(object_name, method, options={})
  options = Util.tags_options(self, options)

  ActionView::Helpers::InstanceTag.new(
    object_name, method, self, options.delete(:object)
  ).to_tags_field_tag(options)
end

#tags_field_tag(name, value, options = {}) ⇒ Object

a standalone tags field tag



118
119
120
# File 'lib/right_rails/helpers/forms.rb', line 118

def tags_field_tag(name, value, options={})
  text_field_tag name, value, Util.tags_options(self, options)
end