Hi all,
I need some support or ideas.
I have a with 2 objects, tickets and users. My tickets has a relation to users.
$this->belongsTo(‘Users’, [
‘foreignKey’ => ‘id’,
]);
When I now call action add, I got standard from where I can add my tickets.
The users are filled in a Form control and on HTML output, there will be an select box with options where I can choose a user.
But in this select, I cannot filter the users list.
I need something, where I can add some filters to filter the users list to make it shorter and then choose one of them.
Is there some possibility? Do I have to implement a Popup where the list of users is shown?
Thanks for your ideas.
greetz efjot
I done similar in a modal in an object.
An example is using a lookup table: https://laracasts.com/discuss/channels/laravel/can-i-redirect-a-get-request-to-a-post-request-for-inertia-partial-reloads?page=1&replyId=905775
This was laravel but would be the same in any language or framework.
Thanks a lot for sending info. I will watch the video
Do you mean with “filter” to only put some users in the list OR to select some users from the list.
- If you need to only put certain users into the select list, you have to filter them out in your controller before you do
$this->set('users', $users);
- If you want to have a filter in the list of users select, you can use select2.
What I have is a List of user
$users = $this->Users->find('list', limit:200);
$this->set('users', $users);
This leads to a select box with all my user inside.
But maybe the List of users in the selectbox contains full list of 200 users and I want to have a possibility to filter this list in the view. Maybe by entering a username or a userID.
But in the standard select box from cake Form->control() there is no pobbibility to do so.
I mean something like this in the screenshot.
scelectBox for choosing a country with possibility to filter the list by entering a name
I mean select2 is exactly what I am looking for
select2 is quite old (besides the fact, that it requires jQuery)
I switched to https://slimselectjs.com/ for quite some time and am pretty pleased with it.
Cool, thanks for the link Slimselect offers even an addable callback what I was missing in sleect2.