@@ -21,7 +21,7 @@ Column(
21
21
child: Column(
22
22
children: <Widget>[
23
23
FormBuilderFilterChip(
24
- attribute : 'filter_chip',
24
+ name : 'filter_chip',
25
25
decoration: InputDecoration(
26
26
labelText: 'Select many options',
27
27
),
@@ -39,7 +39,7 @@ Column(
39
39
],
40
40
),
41
41
FormBuilderChoiceChip(
42
- attribute : 'choice_chip',
42
+ name : 'choice_chip',
43
43
decoration: InputDecoration(
44
44
labelText: 'Select an option',
45
45
),
@@ -57,14 +57,14 @@ Column(
57
57
],
58
58
),
59
59
FormBuilderColorPickerField(
60
- attribute : 'color_picker',
60
+ name : 'color_picker',
61
61
// initialValue: Colors.yellow,
62
62
colorPickerType: ColorPickerType.MaterialPicker,
63
63
decoration: InputDecoration(labelText: 'Pick Color'),
64
64
),
65
65
FormBuilderChipsInput(
66
66
decoration: InputDecoration(labelText: 'Chips'),
67
- attribute : 'chips_test',
67
+ name : 'chips_test',
68
68
onChanged: _onChanged,
69
69
initialValue: [
70
70
Contact('Andrew', '[email protected] ',
@@ -116,7 +116,7 @@ Column(
116
116
},
117
117
),
118
118
FormBuilderDateTimePicker(
119
- attribute : 'date',
119
+ name : 'date',
120
120
// onChanged: _onChanged,
121
121
inputType: InputType.time,
122
122
decoration: InputDecoration(
@@ -127,7 +127,7 @@ Column(
127
127
// readonly: true,
128
128
),
129
129
FormBuilderDateRangePicker(
130
- attribute : 'date_range',
130
+ name : 'date_range',
131
131
firstDate: DateTime(1970),
132
132
lastDate: DateTime(2030),
133
133
format: DateFormat('yyyy-MM-dd'),
@@ -139,7 +139,7 @@ Column(
139
139
),
140
140
),
141
141
FormBuilderSlider(
142
- attribute : 'slider',
142
+ name : 'slider',
143
143
validator: FormBuilderValidators.compose([
144
144
FormBuilderValidators.min(context, 6),
145
145
]),
@@ -155,7 +155,7 @@ Column(
155
155
),
156
156
),
157
157
FormBuilderCheckbox(
158
- attribute : 'accept_terms',
158
+ name : 'accept_terms',
159
159
initialValue: false,
160
160
onChanged: _onChanged,
161
161
title: RichText(
@@ -185,7 +185,7 @@ Column(
185
185
]),
186
186
),
187
187
FormBuilderTextField(
188
- attribute : 'age',
188
+ name : 'age',
189
189
decoration: InputDecoration(
190
190
labelText:
191
191
'This value is passed along to the [Text.maxLines] attribute of the [Text] widget used to display the hint text.',
@@ -200,7 +200,7 @@ Column(
200
200
keyboardType: TextInputType.number,
201
201
),
202
202
FormBuilderDropdown(
203
- attribute : 'gender',
203
+ name : 'gender',
204
204
decoration: InputDecoration(
205
205
labelText: 'Gender',
206
206
),
@@ -220,7 +220,7 @@ Column(
220
220
decoration: InputDecoration(
221
221
labelText: 'Country',
222
222
),
223
- attribute : 'country',
223
+ name : 'country',
224
224
onChanged: _onChanged,
225
225
itemBuilder: (context, country) {
226
226
return ListTile(
@@ -248,7 +248,7 @@ Column(
248
248
FormBuilderRadioList(
249
249
decoration:
250
250
InputDecoration(labelText: 'My chosen language'),
251
- attribute : 'best_language',
251
+ name : 'best_language',
252
252
onChanged: _onChanged,
253
253
validator: FormBuilderValidators.compose(
254
254
[FormBuilderValidators.required(context)]),
@@ -261,7 +261,7 @@ Column(
261
261
),
262
262
FormBuilderTouchSpin(
263
263
decoration: InputDecoration(labelText: 'Stepper'),
264
- attribute : 'stepper',
264
+ name : 'stepper',
265
265
initialValue: 10,
266
266
step: 1,
267
267
iconSize: 48.0,
@@ -270,7 +270,7 @@ Column(
270
270
),
271
271
FormBuilderRating(
272
272
decoration: InputDecoration(labelText: 'Rate this form'),
273
- attribute : 'rate',
273
+ name : 'rate',
274
274
iconSize: 32.0,
275
275
initialValue: 1.0,
276
276
max: 5.0,
@@ -386,7 +386,7 @@ var options = ["Option 1", "Option 2", "Option 3"];
386
386
387
387
``` dart
388
388
FormBuilderField(
389
- attribute : "name",
389
+ name : "name",
390
390
validator: FormBuilderValidators.compose([
391
391
FormBuilderValidators.required(context),
392
392
]),
@@ -414,6 +414,25 @@ FormBuilderField(
414
414
),
415
415
```
416
416
417
+ ### Programmatically changing field value
418
+ You can either change the value of one field at a time like so:
419
+ ``` dart
420
+ _fbKey.currentState.fields['color_picker'].patchValue(Colors.black);
421
+ ```
422
+ Or multiple field value like so:
423
+ ``` dart
424
+ _fbKey.currentState.patchValue({
425
+ 'age': '50',
426
+ 'slider': 6.7,
427
+ 'filter_chip': ['Test 1'],
428
+ 'choice_chip': 'Test 2',
429
+ 'rate': 4,
430
+ 'chips_test': [
431
+ Contact('Andrew', '[email protected] ', 'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg'),
432
+ ],
433
+ });
434
+ ```
435
+
417
436
## Validation
418
437
The ` validator ` attribute in fields take in a ` FormFieldValidator ` which checks the validity of the field. A ` FormFieldValidator ` returns ` null ` if validation is successful and a ` String ` for the ` errorText ` if validation fails.
419
438
@@ -443,7 +462,7 @@ Available built-in validators include:
443
462
Validation example:
444
463
``` dart
445
464
FormBuilderTextField(
446
- attribute : "age",
465
+ name : "age",
447
466
decoration: InputDecoration(labelText: "Age"),
448
467
validator: FormBuilderValidators.compose([
449
468
FormBuilderValidators.numeric(context, errorText: "La edad debe ser numérica."),
@@ -466,7 +485,7 @@ String _emailError;
466
485
Use the variable as the ` errorText ` within ` InputDecoration `
467
486
``` dart
468
487
FormBuilderTextField(
469
- attribute : 'email',
488
+ name : 'email',
470
489
decoration: InputDecoration(
471
490
labelText: 'Email',
472
491
errorText: _emailError,
@@ -496,7 +515,7 @@ You can also validate a field based on the value of another field
496
515
```
497
516
FormBuilderRadioGroup(
498
517
decoration: InputDecoration(labelText: 'My best language'),
499
- attribute : 'my_language',
518
+ name : 'my_language',
500
519
validator: FormBuilderValidators.required(context),
501
520
options: [
502
521
'Dart',
@@ -510,7 +529,7 @@ FormBuilderRadioGroup(
510
529
.toList(growable: false),
511
530
),
512
531
FormBuilderTextField(
513
- attribute : 'specify',
532
+ name : 'specify',
514
533
decoration:
515
534
InputDecoration(labelText: 'If Other, please specify'),
516
535
validator: (val) {
0 commit comments