Skip to content

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.


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

Development

Successfully merging this pull request may close these issues.

2 participants