Skip to content
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

Fix hardcoded ID field name #43

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

rickyosser
Copy link

Fix idField naming for those DBs where 'id' isn't used as the index-field.

@rickyosser rickyosser closed this Dec 19, 2023
@rickyosser
Copy link
Author

Needs more testing! :)

@rickyosser rickyosser reopened this Dec 19, 2023
@rickyosser
Copy link
Author

Ok, if you don't define the idField in the model the MasterCrud uses the "id" field as the index. Which is the way it should be. There was never a reason to hard-code it. If the idField is defined in the model though this is needed for getting the correct table index into the crud.

@@ -205,7 +205,7 @@ public function initCrud(array $defs, View $view = null)
$crud->setModel($this->model);

if (isset($crud->table->columns[$this->model->title_field])) {
$crud->addDecorator($this->model->title_field, [Table\Column\Link::class, [], [$this->model->table . '_id' => 'id']]);
$crud->addDecorator($this->model->title_field, [Table\Column\Link::class, [], [$this->model->table . '_id' => $this->model->idField]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->model->table . '_id' could be probably replaced with already build name from a reference object

@mvorisek mvorisek changed the title Fix idField naming for those DBs where 'id' isn't used as the index-f… Fix hardcoded ID field name Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants