FormBuilderField::addField()
Add new field by specifying name, type and label
Available since version 0.5.7.
Usage
// basic usage
$formBuilderField = $formBuilderField->addField(string $name);
// usage with all arguments
$formBuilderField = $formBuilderField->addField(string $name, string $type = '', string $label = '', array $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
$name | string | Name of field (_a-zA-Z0-9) |
$type (optional) | string | Type of field, which is Inputfield name minus "Inputfield" prefix, i.e. "Text", "URL", "Select", etc. Default:Text |
$label (optional) | string | Label for this field |
$options (optional) | array | Additional options
|
Return value
FormBuilderField
Returns the added FormBuilderField object
Exceptions
Method can throw exceptions on error:
FormBuilderException
- If name of field being added already exists
FormBuilderField methods and properties
API reference based on ProcessWire core version 3.0.251