5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/helpers/effective_acts_as_email_form_helper.rb', line 5
def email_form_fields(form, action = nil, skip: true, to: nil, variables: nil, partial: nil)
raise('expected a form') unless form.respond_to?(:object)
resource = form.object
unless resource.class.respond_to?(:acts_as_email_form?) || resource.respond_to?("email_form_action=")
raise('expected an acts_as_email_form resource or one that responds to email_form_action')
end
email_template = if action.present? && defined?(EffectiveEmailTemplates)
action.kind_of?(Effective::EmailTemplate) ? action : Effective::EmailTemplate.where(template_name: action).first!
end
email_defaults = form.object.email_form_defaults(action) unless email_template.present?
locals = {
form: form,
email_to: to,
email_skip: skip,
email_action: (action || true),
email_defaults: email_defaults,
email_template: email_template,
email_variables: variables
}
render(partial: (partial || 'effective/acts_as_email_form/fields'), locals: locals)
end
|