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

Lookup field with empty value doesn't show placeholder #572

Open
DarkSide666 opened this issue Oct 8, 2018 · 2 comments · May be fixed by #2209
Open

Lookup field with empty value doesn't show placeholder #572

DarkSide666 opened this issue Oct 8, 2018 · 2 comments · May be fixed by #2209
Assignees

Comments

@DarkSide666
Copy link
Member

One thing i don't like with Lookup field is that if it has placeholder and you select "..." value then it shows that ... value and not make it blank and show placeholder again.

It's small glitch, but annoying :)

@ibelar
Copy link
Contributor

ibelar commented Oct 24, 2018

@DarkSide666 - Best way to do so is by setting the dropdown clearable option to true and not using an empty value, like below:

$form->addField('country3', [
    'Lookup',
    'model'       => new Country($db),
    'placeholder' => 'Search for country by code, LV or UK',
    'search'      => ['name', 'iso', 'iso3'],
    'empty'       => '',
    'settings'    => ['clearable' => true]
]);

This way, the empty string is not returned as a selectable option but you can still clear the input using the X icon. Clearing input this way will reset placeholder text.

screen shot 2018-10-24 at 2 41 39 pm

@ibelar ibelar closed this as completed Oct 24, 2018
@ibelar ibelar reopened this Oct 24, 2018
@romaninsh
Copy link
Member

i like this option, can the drop-down be cleared with the keyboard only?

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 a pull request may close this issue.

3 participants