fix: add validation form data id card
This commit is contained in:
		| @@ -176,7 +176,9 @@ class SubmitDataIdCard extends StatelessWidget { | ||||
|           return SingleChildScrollView( | ||||
|             child: Consumer<SubmissionDataViewModel>( | ||||
|                 builder: (context, provider, child) { | ||||
|               return Column( | ||||
|               return Form( | ||||
|                 key: provider.formKeySubmitIdCard, | ||||
|                 child: Column( | ||||
|                   crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                   children: [ | ||||
|                     const TextCaption( | ||||
| @@ -184,14 +186,35 @@ class SubmitDataIdCard extends StatelessWidget { | ||||
|                     TextFormView( | ||||
|                       name: 'NIK', | ||||
|                       keyboardType: TextInputType.number, | ||||
|                       validator: (value) { | ||||
|                         if (value!.isEmpty) { | ||||
|                           return 'Field must be filled'; | ||||
|                         } | ||||
|                         return null; | ||||
|                       }, | ||||
|                     ), | ||||
|                     TextFormView( | ||||
|                       name: 'Full Name', | ||||
|                       validator: (value) { | ||||
|                         if (value!.isEmpty) { | ||||
|                           return 'Field must be filled'; | ||||
|                         } | ||||
|                         return null; | ||||
|                       }, | ||||
|                     ), | ||||
|                   TextFormView(name: 'Full Name'), | ||||
|                     DatePickerView( | ||||
|                       name: 'Birth Date', | ||||
|                       ctrl: provider.ctrlBirthDate, | ||||
|                       maxDate: DateTime.now(), | ||||
|                       isMultipleSelection: false, | ||||
|                       enabled: true), | ||||
|                       enabled: true, | ||||
|                       validatorDate: (value) { | ||||
|                         if (value!.isEmpty) { | ||||
|                           return 'Field must be filled'; | ||||
|                         } | ||||
|                         return null; | ||||
|                       }, | ||||
|                     ), | ||||
|                     photoDocument(provider), | ||||
|                     Container( | ||||
|                       width: SizeConfig.width, | ||||
| @@ -241,14 +264,19 @@ class SubmitDataIdCard extends StatelessWidget { | ||||
|                     ButtonView( | ||||
|                       name: 'Next', | ||||
|                       onPressed: () async { | ||||
|                         if (provider.formKeySubmitIdCard.currentState! | ||||
|                             .validate()) { | ||||
|                           await provider.next(context).then((value) { | ||||
|                             if (value) { | ||||
|                           routePush(context, page: const SubmissionParent()); | ||||
|                               routePush(context, | ||||
|                                   page: const SubmissionParent()); | ||||
|                             } | ||||
|                           }); | ||||
|                         } | ||||
|                       }, | ||||
|                     ) | ||||
|                   ], | ||||
|                 ), | ||||
|               ); | ||||
|             }), | ||||
|           ); | ||||
|   | ||||
| @@ -14,6 +14,8 @@ class SubmissionDataViewModel extends ChangeNotifier { | ||||
|   bool _isEmailVerify = false; | ||||
|   bool get isEmailVerify => _isEmailVerify; | ||||
|   var formKeyPersonalData = GlobalKey<FormState>(); | ||||
|   var formKeySubmitEmail = GlobalKey<FormState>(); | ||||
|   var formKeySubmitIdCard = GlobalKey<FormState>(); | ||||
|   TextEditingController ctrlOccupation = TextEditingController(); | ||||
|   TextEditingController ctrlIncome = TextEditingController(); | ||||
|   TextEditingController ctrlMarital = TextEditingController(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user