Class: AdminAssistant::VirtualColumn::FormView

Inherits:
Column::View
  • Object
show all
Includes:
Column::FormViewMethods
Defined in:
lib/admin_assistant/virtual_column.rb

Direct Known Subclasses

HasManyColumn::FormView

Instance Attribute Summary

Attributes inherited from Column::View

#sort_order

Instance Method Summary collapse

Methods included from Column::FormViewMethods

#after_html, #description, #errors, #field_id, #html, #html_from_helper_method, #render_from_custom_template, #set_instance_variables_from_options

Methods inherited from Column::View

#check_box_and_hidden_tags, #controller, #custom_template_file_path, #file_option_for_custom_template_render, #initialize, #label, #name, #paperclip?, #sort_possible?, #string, #value

Constructor Details

This class inherits a constructor from AdminAssistant::Column::View

Instance Method Details

#default_html(form) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/admin_assistant/virtual_column.rb', line 44

def default_html(form)
  object = form.object
  input_name = "#{@column.model_class.name.underscore}[#{name}]"
  input = @input || :text_field
  html = if input == :check_box
    check_box_and_hidden_tags(input_name, value(object))
  else
    @action_view.send("#{input}_tag", input_name, string(object))
  end
  if has_matching_errors?(object)
    html = "<div class=\"field_with_errors\">#{html}</div>"
  end
  html
end

#has_matching_errors?(record) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/admin_assistant/virtual_column.rb', line 59

def has_matching_errors?(record)
  record.respond_to?(:errors) && record.errors.respond_to?(:[]) && 
     record.errors[name]
end