0

Well, I've got a page with HTML like this:

<form method="post" action="" enctype="multipart/form-data">
<!-- Some more markup -->
<form method="post" action="" enctype="multipart/form-data">
<input type="submit"name="reset_ph" value="<?php _e('Reset styles'); ?>" />
<input type="hidden" name="subaction" value="reset_ph" />
</form>
<p><input name="update" type="submit" value="<?php _e('Save changes'); ?>" style="padding:3px;"  /></p>
<input type="hidden" name="action" value="update"  />
</form>  

Then PHP code:

//updating main form
if(isset($_FILES['phtfile']['name']) && $_REQUEST['action']=='update'){
$def_path = TEMPLATEPATH.'/img/author/';
$file_path = $def_path.basename($_FILES['phtfile']['name']);
$file_path = str_replace('\\','/',$file_path);
$file_css_path = get_bloginfo('template_url');
$file_css_path = $file_css_path.'/img/author/'.basename($_FILES['phtfile']['name']);

$isfile = move_uploaded_file($_FILES['phtfile']['tmp_name'],$file_path);

if ($isfile) { update_option('own_pht_url', $file_css_path);}

}
//update subform    
if ($_POST['subaction']=='reset_ph'){
global $photo_path;
update_option('own_pht_url', $photo_path.'tmp.jpg');
}

Subform contains a button, that resets image shown to default one (via setting path to image to default). Main form contains the image upload dialog, and should change path to image to a new one, should the file be uploaded. But updating the main form, updates the subform, and path is set to default.

I've figured a workaround, by changing the button to a checkbox, but I'm still interested, does updating the master form always updates every sub-form inside it? No ways around it?

Thank you for your time.

Arnthor
  • 2,563
  • 6
  • 34
  • 54

1 Answers1

0

Nested forms are known to cause problems. You can check out this thread:

Why WHATWG disallows nested forms in HTML 4 and HTML5?

Community
  • 1
  • 1
Arnab
  • 736
  • 5
  • 14