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

Is possible to pass a hidden field in the SearchTextFieldItem like an user ID? #80

Closed
Rovel opened this issue Oct 10, 2017 · 5 comments
Closed

Comments

@Rovel
Copy link

Rovel commented Oct 10, 2017

Whats is the best way to pass a user id to a variable as people use SearchTextField, since SearchTextFieldItem has only 3 param, how can I pass a hidden param of find the user id comparing the SearchTextFieldItem to a User List = Users or user the users list as a SearchTextFieldItem with hidden params.

@kamerc
Copy link

kamerc commented Oct 10, 2017

I had the same requirement. I extended SearchTextFieldItem and added an id attribute

@Rovel
Copy link
Author

Rovel commented Oct 10, 2017

Thanks @kamerc, is that extension shared in github or just in your project? I'm curious :)
I used array filter passing a unique atribute from the SearchTextFieldItem, in the complete Users like a user email in the searchTextField.itemSelectionHandler, something like this:
let filteredUser = userArray.filter{ $0.userEmail == item.subtitle }

@kamerc
Copy link

kamerc commented Oct 11, 2017

class MySearchTextFieldItem: SearchTextFieldItem {
    public var id: Int?
    public init(title: String, subtitle: String?, id: Int?) {
        super.init(title: title)
        self.title = title
        self.subtitle = subtitle
        self.id = id
    }
    
}

then use MySearchTextFieldItem in your code where you would have used SearchTextFieldItem

@Rovel
Copy link
Author

Rovel commented Nov 23, 2017 via email

@Milap-Kundalia
Copy link

@kamerc Thanks for the solution but how can I access the ID in selection call back. itemSelectionHandler returns me the custom models but it is not returning the ID in that

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

No branches or pull requests

4 participants