Skip to content

Commit

Permalink
Migration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubert Prein committed Oct 20, 2016
1 parent dba83dc commit 4b96490
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions migrations/m161005_122600_amforms_editFormSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,24 @@ public function safeUp()
->queryAll();
if ($forms) {
foreach ($forms as $form) {
$form = AmForms_FormModel::populateModel($form);

// Set afterSubmit
if (! empty($form->afterSubmitText)) {
$form->afterSubmit = 'afterSubmitText';
}
elseif (! empty($form->redirectEntryId)) {
$form->afterSubmit = 'redirectEntryId';
$afterSubmit = 'afterSubmitText';

if (! empty($form['afterSubmitText'])) {
$afterSubmit = 'afterSubmitText';
}
elseif (! empty($form->redirectUrl)) {
$form->afterSubmit = 'redirectUrl';
elseif (! empty($form['redirectEntryId'])) {
$afterSubmit = 'redirectEntryId';
}
elseif (! empty($form->submitAction)) {
$form->afterSubmit = 'submitAction';
elseif (! empty($form['redirectUrl'])) {
$afterSubmit = 'redirectUrl';
}
else {
$form->afterSubmit = 'afterSubmitText';
elseif (! empty($form['submitAction'])) {
$afterSubmit = 'submitAction';
}

// Save form!
craft()->amForms_forms->saveForm($form);
craft()->db->createCommand()->update('amforms_forms', array('afterSubmit' => $afterSubmit), 'id = :id', array(':id' => $form['id']));
}
}
}
Expand Down

0 comments on commit 4b96490

Please sign in to comment.