Stay organized with collections
Save and categorize content based on your preferences.
blockly > Field > (constructor)
Field.(constructor)
Constructs a new instance of the Field
class
Signature:
constructor(value: T | typeof Field.SKIP_SETUP, validator?: FieldValidator<T> | null, config?: FieldConfig);
Parameters
Parameter |
Type |
Description |
value |
T | typeof Field.SKIP_SETUP |
The initial value of the field. Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by subclasses that want to handle configuration and setting the field value after their own constructors have run). |
validator |
FieldValidator<T> | null |
(Optional) A function that is called to validate changes to the field's value. Takes in a value & returns a validated value, or null to abort the change. |
config |
FieldConfig |
(Optional) A map of options used to configure the field. Refer to the individual field's documentation for a list of properties this parameter supports. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["The `Field` constructor initializes a new field instance with an initial value, an optional validator, and an optional configuration."],["`Field.SKIP_SETUP` can be passed as the initial value to delay field setup for subclasses."],["A validator function can be provided to control and validate changes to the field's value."],["The optional `config` parameter allows for further customization of the field using specific properties."]]],["The `Field` class constructor initializes a new field instance. It accepts three parameters: `value`, `validator`, and `config`. `value` sets the field's initial value or `Field.SKIP_SETUP` for deferred setup. `validator` is an optional function to validate value changes, returning a validated value or null. `config`, also optional, is a map of field-specific configuration options. These parameters enable setting the initial state and defining constraints.\n"]]