I’m having a strange problem saving data with cakePHP. I’ll explain as I go.
This is the controller header just in case its useful:
var $helpers = array('Html','Form','Js','Ajax');
var $components = array('RequestHandler');
var $name = 'Parts';
var $paginate = array(
'limit'=>25,
'order'=>array('Part.customer'=>'asc')
);
This is my controller code for saving the form data:
//list items for table
$parts = $this->Paginate('Part');
$this->set('parts',$parts); ]
//save data
if(!empty($this->data)){
if ($this->Part->save($this->data)) {
$this->Session->setFlash('Part added to database.','default',array('class'=>'flash-success'));
$this->redirect(array('action' => 'index'));
}else{
$this->Session->setFlash('Failed to add part to database, please try again.','default',array('class'=>'flash-failure'));
$this->redirect(array('action' => 'index'));
}
}
This is my form in the view:
echo $this->Form->create('Part');
echo $this->Form->input('customer');
echo $this->Form->input('part_number');
echo $this->Form->input('foil');
echo $this->Form->input('base');
echo $this->Form->input('base_color');
echo $this->Form->input('description',array('cols'=>21));
echo $this->Form->input('moulding');
echo $this->Form->input('foil_diameter');
echo $this->Form->input('tool');
echo $this->Form->input('impressions');
echo $this->Form->input('spray_jig');
echo $this->Form->input('prep');
echo $this->Form->input('pack');
echo $this->Form->end('Add Part');
Now, if I enter information into the form upto and including spray_jig the from will save and the data will be saved. If I fill the form before spray_jig the form will not submit. I haven’t got any data validation going on yet and the fields are a mixture of VARCHAR’s INT’s and one TEXT.
This has me baffled, can you suggest the problem and/or a good way to troubleshoot?
Note: spray_jig is standard int(11) field.
I found the solution – it appears INT fields cannot have null values. Once all INT fields where entered, the form submits.