[eluser]abbe01[/eluser]
I have bumped into an error as while I have 2 submit button within 1 form, which is update and export submit button. The form is sent to templates/misc for process. Below is my code in codeigniter
1) View:
Code:
<?php
$attributes1 = array('name' => 'updateform');
echo form_open("?".$path.'misc',$attributes1);
?>
<span id="spec-header"> Resource : <?php echo $put_in;?> </span><br />
<textarea name="tmpl_content" cols="100" rows="40">
<?php
echo $file_details['file'][$look_up];
?>
</textarea>
<br />
<input type="hidden" name="templatename" value="<?php echo $templatename;?>" />
<input type="hidden" name="templatefileid" value="<?php echo $tmpl_fileid; ?>" />
<input type="hidden" id="templateid" name="templateid" value="<?php echo $templateid ;?>" />
<input type="submit" name="updatetemplate" value="Update" class="submit0" />
<input type="submit" name="exporttemplate" value="Export Template" class="submit1" />
</form>
2) Controller
Code:
function misc(){
$templateid = trim($_POST['templateid']);
if ($_POST['updatetemplate']){
$this->Templates_Model->update_template();
redirect($this->path."view/".$templateid);
exit;
}
if ($_POST['exporttemplate']){
//echo "here";
$this->export_template();
}
}
But, once I have 2 submit button and either one button I submit, it will give me error say undefined index updatetemplate(if i submit exporttemplate). What's wrong with the code? Can't have more than 1 submit button at one form? Thanks.