public function actionDeleteForm()
{
$this->requirePostRequest();
// Get form if available
$formId = craft()->request->getRequiredPost('formId');
$form = craft()->amForms_forms->getFormById($formId);
if (!$form) {
throw new Exception(Craft::t('No form exists with the ID “{id}”.', array('id' => $formId)));
}
// Delete form
if (craft()->amForms_forms->deleteForm($form)) {
craft()->userSession->setNotice(Craft::t('Form deleted.'));
} else {
craft()->userSession->setError(Craft::t('Couldn’t delete form.'));
}
$this->redirectToPostedUrl($form);
}