Skip to content

Commit

Permalink
fix missing script
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Aug 17, 2022
1 parent 6f97b90 commit 649976f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion _config/pure-modal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Name: pure-modal
---
LeKoala\PureModal\PureModal:
move_modal_to_body: true
move_modal_to_body: false
overlay_triggers_close: true
compute_iframe_height: false
edit_form_id: 'Form_ItemEditForm'
20 changes: 19 additions & 1 deletion src/PureModalAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,30 @@ public function getOverlayTriggersClose()
return PureModal::getOverlayTriggersCloseConfig();
}

/**
* If the modal is in the body, it needs to go back to the form to submit properly
* @return string
*/
public function SubmitOnClickScript()
{
if (!PureModal::getMoveModalScript()) {
return '';
}
$formId = PureModal::config()->edit_form_id;
return "var f=document.getElementById('$formId');f.appendChild(this.closest('.pure-modal'));f.submit();";
}

/**
* Move modal when clicking on the open button. Trigger only once.
* @return string
*/
public static function getMoveModalScript()
{
if (!PureModal::config()->move_modal_to_body) {
return '';
}
return "document.getElementById('Form_ItemEditForm').appendChild(this.parentElement.querySelector('.pure-modal'));this.onclick=null;";
$formId = PureModal::config()->edit_form_id;
return "document.getElementById('$formId').appendChild(this.parentElement.querySelector('.pure-modal'));this.onclick=null;";
}

public function getAttributes()
Expand Down

0 comments on commit 649976f

Please sign in to comment.