I have a form (greatly simplified):
<form action='http://example.com/' method='post' name='event_form'>
<input type='text' name='foo' value='3'/>
<input type='submit' name='event_submit' value='Edit'/>
</form>
And I have a class "EventForm" to process the form. The main method, process() looks like this:
public function process($submitname=false){
$success=false;
if ($submitname && isset($_POST[$submitname])){ //PROBLEM: isset($_POST[$submitname] is always FALSE for some reason
if($success=$this->ruler->validate()){//check that dependancies are honoured and data types are correct
if($success=$this->map_fields()){//divide input data into Event, Schedule_Element and Temporal_Expression(s)
$success=$this->eventholder->save();
}
}
} else {//get the record from the db based on event_id or schedule_element_id
foreach($this->gets as $var){//list of acceptable $_GET keys
if(isset($_GET[$var])){
if($success= $this->__set($var,$_GET[$var])) break;
}
}
}
$this->action=(empty($this->eventholder->event_id))? ADD : EDIT;
return $success;
}
When the form is submitted, this happens: $form->process('event_submit');
For some reason though, isset($_POST['event_submit'])
always evaluates to FALSE. Can anyone see why?
ETA: after working through the suggestions, it appears that JQuery.validate() is having an unexpected effect on the form submission. All the fields are submitted except the submit button. This appears to be the fault of this JQuery:
$("form[name='event_form']").validate({
submitHandler: function(form) {
form.submit();
}
}};
Any thoughts on how to make sure the submit button value gets sent?