How to get current entry id or current entry in list operation? #1289
Replies: 3 comments
-
The In the List operation, you're dealing with multiple entries, so there isn't a concept of a "current" entry. These methods will return false or null in the List operation context. If you need to access individual entry IDs in the List operation, you should iterate through the entries returned by the List operation. You can use the $entries = $this->crud->getEntries();
foreach ($entries as $entry) {
$id = $entry->id;
// Do something with the ID
} This approach is mentioned in the CRUD API documentation: $this->crud->getEntries(); If you need to perform actions on individual entries in the List operation, you might want to consider using column buttons or bulk actions instead, which are designed for interacting with specific entries in the list context. Remember that ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: fix: getCurrentEntryId() should return null instead of false |
Beta Was this translation helpful? Give feedback.
-
Hey @blessen131 The bot is explaining it right. The
$this->crud->operation('list', function() {
$this->crud->setAccessCondition(['update', 'delete'], function ($entry) {
return $entry->id===1 ? true : false;
});
}); |
Beta Was this translation helpful? Give feedback.
-
Closing the discussion, please feel free to reopen if there is something I missed to answer. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
getCurrentEntryId and getCurrentEntry is returning false in ListOperation
$this->crud->getCurrentEntryId()
$this->crud->getCurrentEntry()
Beta Was this translation helpful? Give feedback.
All reactions