tombenner/wp-mvc

Upload will insert new row when setup primary key at model ?

Closed this issue · 1 comments

When i change primary key at model to new character ID, After saved will add new row, not update this row, I found cause and fixed
At line 30 core/helpers/mvc_form_helper.php
$html .= '<input type="hidden" id="'.$this->input_id('hidden_id').'" name="'.$this->input_name('id').'" value="'.$object_id.'" />';
Replace to below:
$html .= '<input type="hidden" id="'.$this->input_id('hidden_id').'" name="data['.$this->model->name.']['.$this->model->primary_key.']" value="'.$object_id.'" />';
Thanks