Search code examples
phpformspostgetuikit

Form input in modal an out of modal, cant POST all data


Peace, I have a form with different details, Part of the form is in standard DIV, and some is in MODAL. I can not send POST data filled in MODAL. This is the code

<form id="vg_frm" name="vg_frm" action="php/card.php" method="POST" enctype="multipart/form-data">
   <input class="uk-checkbox" value="fff" type="radio" name="radio2" />
   <input type="text" name="grid" id="grid" value="vvv">
   <input type="hidden" name="h_bg_color" id="h_bg_color" value=''>




<div uk-modal>
<div class="uk-modal-dialog uk-modal-body uk-overflow-auto"
     <input type="file" name="bg_img" id="bg_img">
     <input value="yes" class="uk-checkbox" type="checkbox" name="remove_bg_img" id="remove_bg_img">
</div>  
</div>

    <button type="submit" name="submit_style_frm" id="submit_style_frm">ok</button>
 </form>

Data from input file (bg_img) and checkbox (remove_bg) not recieved

card.php

print_r($_POST);

Solution

  • Thanks to everyone who tried to help. After digging in HTML, I saw that once I open MODAL, JS of UIKIT moves the DIV to the end of HTML, which causes it not to be within the FORM tags. I found a UIKIT setting that needs to be added to MODAL so it will not happen.

    "container: false Sets the MODAL to open in its place rather than at the end of HTML