Class: Toolbox::ControlRenderer

Inherits:
Renderer
  • Object
show all
Defined in:
lib/toolbox/rendering.rb

Instance Attribute Summary

Attributes inherited from Renderer

#widget_config

Instance Method Summary collapse

Methods inherited from Renderer

#initialize, #label, #translate_field, #value

Constructor Details

This class inherits a constructor from Toolbox::Renderer

Instance Method Details

#render_control(form, rec, has_error = false) ⇒ Object



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/toolbox/rendering.rb', line 206

def render_control(form, rec, has_error = false)
  options = {}
  options[:class] = 'error' if has_error
  options[:class] = (options[:class] || '') + ' ' + @widget_config.css_class if @widget_config.css_class       
  options[:id] = "dialog_#{form.tag_id @widget_config.name}" if @dialog
  options[:title] = @view.send(:h, @widget_config.info) if @widget_config.info
  options[:disabled] = @widget_config.disabled if @widget_config.disabled and not @widget_config.disabled.is_a?(Proc)
  options[:disabled] = @widget_config.disabled.call(rec) if @widget_config.disabled.is_a?(Proc)

  case @widget_config.type
  when :select
    render_select form, rec, options
  when :collection_select
    render_collection_select form, rec, options
  when :auto_complete
    render_autocomplete form, rec, options
  when :radio
    render_radio form, rec, options
  when :check_box
    render_checkbox form, rec, options
  when :date
    render_date form, rec, options
  when :textfield
    render_textfield form, rec, options
  when :textarea
    render_textarea form, rec, options
  when :filefield
    render_filefield form, rec, options
  when :hidden
    render_hidden form, rec, options
  else          
    raise "Unkown control type #{@widget_config.type}"
  end
end