2amigos / yii2-grid-view-library

Highly enhanced GridView widget and grid components for Yii2
https://2amigos.us
Other
57 stars 16 forks source link

EditableColumn not working with composite keys #14

Closed ifcanduela closed 9 years ago

ifcanduela commented 9 years ago

The EditableColumn widget fails when used with models which have composite primary keys.

I traced the problem back to line 104 of EditableColumn.php, in which the data-pk field is passed alongside other HTML attributes to the HTML::a() method. In my case data-pk contains a $key that is an associative array, so the HTML attributes array is invalid.

I fixed this by using

$this->options['data-pk'] = base64_encode(serialize($key));

In line 100 of EditableColumn.php and

$pk = unserialize(base64_decode($pk));

in line 62 of EditableAction.php (from the other repo), but this change might have unintended consequences if other widgets are used.

tonydspaniard commented 9 years ago

Thank you @ifcanduela!

Do you have time for a working pull request that I could test afterwards?

Edit:

but this change might have unintended consequences if other widgets are used.

Mind extending this?

ifcanduela commented 9 years ago

Sure: I´ve only changed the parts that made the EditableColumn widget work for me, and I don't have any experience with the remaining code of any of the two packages (I think it´s only the Editable widget, I´m talking about). Maybe I can setup a test project today.

I will prepare pull requests for both repos then, and if you have a test suite you can confirm it works.

ifcanduela commented 9 years ago

I submitted a pull request for this repo (#15) and yii2-editable-widget (https://github.com/2amigos/yii2-editable-widget/pull/7)

tonydspaniard commented 9 years ago

Thank you so much @ifcanduela will update version tags

ifcanduela commented 9 years ago

Hola Toni,

after composer updateing my app, I see that there's an error in EditableAction.php. I will send a new pull request (for the editable-widget repo, actually). I'm really sorry for this.

Qué bochorno, madre mía.