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

ReactiveDropdownSearchMultiSelection - Validators.required works only once #98

Closed
leaderrr767 opened this issue May 1, 2023 · 3 comments

Comments

@leaderrr767
Copy link

Hi, folks.

Validators.required works only once for ReactiveDropdownSearchMultiSelection.

How to reproduce:

  1. Run the code
  2. Press "Validate!" -> Validation message "Required!" appears. Good.
  3. Choose 1 or more items within ReactiveDropdownSearchMultiSelection -> Validation message "Required!" disappears. Good.
  4. Remove all items from ReactiveDropdownSearchMultiSelection -> Validation message "Required!" don't appear.
  5. Press "Validate!" -> Validation message "Required!" don't appear. Sad.

Update:
As a walkaround I use Validators.Required in combination with Validators.minLength(1).

Form


final test_form =fb.group({
  'multi_field': FormControl<List<String>>(validators: [Validators.required]),
});

Model


List<String> test_form_items=['item1', 'item2', 'item3'];

View


          ReactiveForm(
              formGroup: test_form,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: ReactiveDropdownSearchMultiSelection<String,String>(
                  validationMessages: {
                    ValidationMessage.required: (error) => 'Required!',
                  },
                  formControlName: 'multi_field',
                  items: test_form_items,
                ),
              ),
          ),
          SizedBox(height: 50,),
          OutlinedButton(
              onPressed: (){
                test_form.markAllAsTouched();
              },
              child: Text('Validate!'))
@vasilich6107
Copy link
Contributor

Hi @leaderrr767
This is an issue with validator
joanpablo/reactive_forms#377

It does not handle empty lists and maps properly

@vasilich6107
Copy link
Contributor

wait for joanpablo/reactive_forms#378

@vasilich6107
Copy link
Contributor

vasilich6107 commented May 10, 2023

as far as im casting null to [] i decided to cast back the value for consistency)
check reactive_dropdown_search 1.0.1

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

2 participants