Skip to content

Commit

Permalink
Improved documentation for FormBuilderCustomField
Browse files Browse the repository at this point in the history
  • Loading branch information
danvick committed May 27, 2019
1 parent 990d009 commit d63b8fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ In order to create an input field in the form, along with the label, and any app
| `valueTransformer` | `ValueTransformer<T>` | `null` | `false` | Function that transforms field value before saving to form value. e.g. transform TextField value for numeric field from `String` to `num` |
The rest of the attributes will be determined by the type of Widget being used.

### Building your own custom `FormField`
### Building your own custom field
To build your own field within a `FormBuilder`, we use `FormBuilderCustomField` which will require that you define your own `FormField`.
The `FormField` will not require a `validator` if the `validators` property is already defined in the `FormBuilderCustomField`.

```dart
FormBuilderCustomField(
attribute: "name",
Expand Down
11 changes: 11 additions & 0 deletions lib/src/form_builder_custom_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';

class FormBuilderCustomField<T> extends StatefulWidget {
/// Identifier for the field input.
///
/// Used as a key to final map returned when the form is submitted
final String attribute;

/// The [FormField] widget that will house the custom input
final FormField<T> formField;

/// An optional list of [FormFieldValidator]s that validates the input in the field.
final List<FormFieldValidator> validators;

/// Called before field value is submitted.
///
/// Can be used to convert the value to the output expected by the user.
final ValueTransformer valueTransformer;

FormBuilderCustomField({
Expand Down

0 comments on commit d63b8fa

Please sign in to comment.