-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update/View buttons broken if table/model has composite primary keys #14
Comments
can you provide your SQL? |
This item should be reproducible by creating a table/model with a composite primary key and running the CRUD app. You will see that you can't update or delete a record until you manually put the rest of the composite key fields into the update/delete button's code as listed above. |
Whew.. could you help me to fix this? |
Did you find what you needed? The ticket says closed is why I ask. I can provide example how to fix if still necessary. |
Hi, maybe your database schema is not right, did u use foreign keys? did your database have 2 primary keys? i've tried on my schema and it's working properly... |
this is my schema
|
When creating a view using a model with a composite primary key, the composite key is not copied over to the 'Update' button on the View or Index pages which causes the buttons to break (with a composite key; because Yii is looking for the ID's of the composite keys too.
As a workaround:
$model['id'], **'entity_id' => $model['entity_id'], 'label_id' => $model['label_id'**]], ['class' => 'btn btn-primary']) ?>If for example, your additional primary keys (besides id) are entity_id and label_id, the primary keys must be added to the 'update' button's code in the View file, like so:
The text was updated successfully, but these errors were encountered: