Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Oct 21, 2020
1 parent ac42bb3 commit 10dfdbf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/Actions/FormAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ protected function action(): Response
$this->request->getUploadedFiles()
);
$formValidator->validate();
$form->getMeta('saveButton') !== false && $form->persist();

if ($form->getMeta('saveButton') !== false) {
$form->persist();
}

if ($form->isValid() && $form->getMode() === Form::MODE_SEND) {
$this->mailer->sendForm($form);
Expand Down
13 changes: 5 additions & 8 deletions src/FormGenerator/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ public function getMode()
*/
public function submit(array $data, array $files)
{
// Important! Restore persisted data first to determine if UploadFormElements
// have already an uploaded file (They have a value which contains the file
// name)
// FIXME is this still necessary?
$this->restore();

// submit data
foreach ($this->formElements as $formElement) {
$this->submitFormElement($formElement, $data, $files);
Expand Down Expand Up @@ -439,8 +433,11 @@ protected function setDefaultValues(AbstractFormElement $formElement)
$this->setDefaultValues($fieldsetChild);
}
} elseif ($formElement instanceof ChecklistFormElement
|| $formElement instanceof DropdownFormElement) {
$formElement->setDefaultValue();
|| $formElement instanceof DropdownFormElement
) {
if (! $formElement->hasValue()) {
$formElement->setDefaultValue();
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/FormGenerator/FormElements/ChecklistFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class ChecklistFormElement extends AbstractDynamicFormElement
public function setDefaultValue()
{

if ($this->getValue()) {
return;
}

$defaultValue = $this->getConfigValue('default');

if ($defaultValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/FormGenerator/FormElements/DropdownFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DropdownFormElement extends AbstractDynamicFormElement
*
* @return void
*/
public function setdefaultvalue()
public function setDefaultValue()
{
if ($this->getValue()) {
return;
Expand Down

0 comments on commit 10dfdbf

Please sign in to comment.