def extjs_field(field, config=nil)
if config.kind_of? Hash
if config.has_key?(:mapping) && config.has_key?(:parent_trail)
field.update(
:name => config[:parent_trail].to_s + self.extjs_parent_trail_template.call(field[:name]),
:mapping => "#{config[:mapping]}.#{field[:name]}"
)
end
field.update(config.except(:mapping, :parent_trail))
elsif !config.nil?
field.update(
:allowBlank => self.extjs_allow_blank(config),
:type => self.extjs_type(config),
:defaultValue => self.extjs_default(config)
)
field[:dateFormat] = "c" if field[:type] === "date" && field[:dateFormat].nil?
end
field.update(:type => "auto") if field[:type].nil?
field.keys.each do |k|
raise ArgumentError, "extjs_field expects a Hash as first parameter with all it's keys Symbols. Found key #{k.inspect}:#{k.class.to_s}" unless k.is_a?(Symbol)
field[k] = field[k].to_s if field[k].is_a?(Symbol)
end
field
end