maricris-sn
10/23/2010 - 9:12 AM

As seen in: http://coderkitty.sweetperceptions.com/2009/3/9/extending-database_form-to-send-emails-via-mailer-extension

## vendor/extensions/database_form/app/models/database_form_page.rb

  # Save form data
  def save_form
    form_response = FormResponse.new(:name => form_name)
    form_response.content = form_data
    if !form_response.save
      @form_error = "Error encountered while trying to submit form. #{$!}"
      false
    else 
      send_static_email(form_data) unless self.parts.find_by_name('mailer').blank?
      true
    end
  end

  def send_static_email(form_data)
    mailer_config = YAML::load(self.parts.find_by_name('mailer').content).symbolize_keys
    mail = Mail.new(self, mailer_config, form_data)
    mail.send
  end