tags:

views:

91

answers:

1

Hi, I need some idea in Saving the Form entries..

 In my app, i have designed the form using Cakephp and JQuery, saved the form and can view the form ..

 While i fill the entries in the form it is saved in my Table Results
 My results table is having (id,form_id,attribute_id,label,value)

 I can view the form n times and can fill the datas n times..
 But i didnt kept anything regarding Entry Number ..

 Like if i submitted my form once it should be the Entry 1 ..And later on if i open the form again and fill it it should be the entry 2.
  How could i do so.Please suggest me...
A: 

If you want to count the numer of times you've revised each row in your table, then simply create a column named revision_number in your table with a default of 0. Then in your model do something like this:

function beforeSave() {
  $currentRevision = $this->field('revision_number');
  $this->data[$this->alias]['revision_number'] = ($currentRevision + 1);
  return parent::beforeSave()
}

This will increment your field every time you save the item.

thief