Skip to main content

GravityKit\GravityMigrate\Schema\UniversalField

Represents a form field in a platform-agnostic format.

The canonical shape every supported plugin's field is converted to and from. What one platform keeps that this shape has no room for goes into extensions.

Since: %ver%

Source: src/Schema/UniversalField.php:18

Details​

  • Kind: class

  • Namespace: GravityKit\GravityMigrate\Schema

  • Implements: JsonSerializable

Properties​

PropertyTypeDescription
$idint | stringUnique identifier within the form.
$typestringUniversal field type.
$labelstringField label.
$descriptionstringField description.
$requiredboolWhether field is required.
$placeholderstringPlaceholder text.
$default_valuemixedDefault value.
$css_classstringCSS classes.
$admin_labelstringAdmin label.
$page_numberintPage number (for multi-page forms).
$sizestringField size (small, medium, large), or empty when the platform did not say.
$choicesChoice[]The options a select, radio, checkbox or product field offers.
$inputsInput[]The parts of a composite field.
$conditional_logicUniversalConditionalLogic | nullWhen this field appears.
$conditional_logic_payloadarray | nullThe rules in the spelling the platform that wrote them uses.
$extensionsExtensionDataPlatform-specific extensions.
$transformation_logTransformationLog | nullTransformationLog tracking.
$source_field_idsarrayOriginal field IDs from source (for composite tracking).
$is_recomposedboolWhether this field was created by recomposition.

Methods​

MethodDescription
__construct()Constructor.
add_source_field_id()Adds a source field ID.
get_id()Gets field ID.
set_id()Sets field ID.
get_type()Gets field type.
set_type()Sets field type.
get_label()Gets field label.
set_label()Sets field label.
get_description()Gets field description.
set_description()Sets field description.
is_required()Checks if field is required.
set_required()Sets required status.
get_placeholder()Gets placeholder.
set_placeholder()Sets placeholder.
get_default_value()Gets default value.
set_default_value()Sets default value.
get_css_class()Gets CSS class.
set_css_class()Sets CSS class.
get_admin_label()Gets admin label.
set_admin_label()Sets admin label.
get_page_number()Gets page number.
set_page_number()Sets page number.
get_size()Gets field size.
set_size()Sets field size.
get_choices()The options this field offers, in the array form adapters read.
choices()The options this field offers.
set_choices()Sets the options this field offers.
add_choice()Adds one option.
get_inputs()The parts of this field, in the array form adapters read.
inputs()The parts of this field.
set_inputs()Sets the parts of this field.
add_input()Adds one part.
get_conditional_logic()When this field appears, in the array form adapters read.
conditional_logic()When this field appears.
has_conditional_logic()Whether anything governs when this field appears.
set_conditional_logic()Sets when this field appears.
get_extensions()Gets extensions.
set_extensions()Sets extensions.
get_transformation_log()Gets transformation log.
set_transformation_log()Sets transformation log.
get_source_field_ids()Gets source field IDs.
set_source_field_ids()Sets source field IDs.
is_recomposed()Checks if field was recomposed.
set_recomposed()Sets recomposed flag.
from_array()Creates from array.
to_array()Converts to array.

Method Reference​

__construct()​

public function __construct( $id, string $type, string $label='' )

Constructor.

Parameters​

NameTypeDefaultDescription
$idint | stringField ID.
$typestringField type.
$labelstring''Field label.

Since: %ver%

Source: src/Schema/UniversalField.php:404

add_source_field_id()​

public function add_source_field_id( $field_id ): self

Adds a source field ID.

Parameters​

NameTypeDefaultDescription
$field_idint | stringSource field ID.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:420

get_id()​

public function get_id()

Gets field ID.

Returns​

  • int | string

Since: %ver%

Source: src/Schema/UniversalField.php:433

set_id()​

public function set_id( $id ): self

Sets field ID.

Parameters​

NameTypeDefaultDescription
$idint | stringField ID.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:446

get_type()​

public function get_type(): string

Gets field type.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:459

set_type()​

public function set_type( string $type ): self

Sets field type.

Parameters​

NameTypeDefaultDescription
$typestringField type.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:472

get_label()​

public function get_label(): string

Gets field label.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:485

set_label()​

public function set_label( string $label ): self

Sets field label.

Parameters​

NameTypeDefaultDescription
$labelstringField label.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:498

get_description()​

public function get_description(): string

Gets field description.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:511

set_description()​

public function set_description( string $description ): self

Sets field description.

Parameters​

NameTypeDefaultDescription
$descriptionstringField description.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:524

is_required()​

public function is_required(): bool

Checks if field is required.

Returns​

  • bool

Since: %ver%

Source: src/Schema/UniversalField.php:537

set_required()​

public function set_required( bool $required ): self

Sets required status.

Parameters​

NameTypeDefaultDescription
$requiredboolRequired status.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:550

get_placeholder()​

public function get_placeholder(): string

Gets placeholder.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:563

set_placeholder()​

public function set_placeholder( string $placeholder ): self

Sets placeholder.

Parameters​

NameTypeDefaultDescription
$placeholderstringPlaceholder text.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:576

get_default_value()​

public function get_default_value()

Gets default value.

Returns​

  • mixed

Since: %ver%

Source: src/Schema/UniversalField.php:589

set_default_value()​

public function set_default_value( $default_value ): self

Sets default value.

Parameters​

NameTypeDefaultDescription
$default_valuemixedDefault value.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:602

get_css_class()​

public function get_css_class(): string

Gets CSS class.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:615

set_css_class()​

public function set_css_class( string $css_class ): self

Sets CSS class.

Parameters​

NameTypeDefaultDescription
$css_classstringCSS class string.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:628

get_admin_label()​

public function get_admin_label(): string

Gets admin label.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:641

set_admin_label()​

public function set_admin_label( string $admin_label ): self

Sets admin label.

Parameters​

NameTypeDefaultDescription
$admin_labelstringAdmin label.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:654

get_page_number()​

public function get_page_number(): int

Gets page number.

Returns​

  • int

Since: %ver%

Source: src/Schema/UniversalField.php:667

set_page_number()​

public function set_page_number( int $page_number ): self

Sets page number.

Parameters​

NameTypeDefaultDescription
$page_numberintPage number.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:680

get_size()​

public function get_size(): string

Gets field size.

Returns​

  • string

Since: %ver%

Source: src/Schema/UniversalField.php:693

set_size()​

public function set_size( string $size ): self

Sets field size.

Parameters​

NameTypeDefaultDescription
$sizestringField size.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:706

get_choices()​

public function get_choices(): array

The options this field offers, in the array form adapters read.

Read choices() for the objects themselves.

Returns​

  • array

Since: %ver%

Source: src/Schema/UniversalField.php:721

choices()​

public function choices(): array

The options this field offers.

Returns​

  • Choice[]

Since: %ver%

Source: src/Schema/UniversalField.php:735

set_choices()​

public function set_choices( array $choices ): self

Sets the options this field offers.

Takes Choice objects, and the arrays adapters hand over.

Parameters​

NameTypeDefaultDescription
$choicesarrayChoice objects, or choice arrays.

Returns​

  • self

Throws​

  • \InvalidArgumentException — When an entry is neither.

Since: %ver%

Source: src/Schema/UniversalField.php:752

add_choice()​

public function add_choice( Choice $choice ): self

Adds one option.

Parameters​

NameTypeDefaultDescription
$choiceChoiceThe option.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:771

get_inputs()​

public function get_inputs(): array

The parts of this field, in the array form adapters read.

Read inputs() for the objects themselves.

Returns​

  • array

Since: %ver%

Source: src/Schema/UniversalField.php:786

inputs()​

public function inputs(): array

The parts of this field.

Returns​

  • Input[]

Since: %ver%

Source: src/Schema/UniversalField.php:800

set_inputs()​

public function set_inputs( array $inputs ): self

Sets the parts of this field.

Takes Input objects, and the arrays adapters hand over.

Parameters​

NameTypeDefaultDescription
$inputsarrayInput objects, or input arrays.

Returns​

  • self

Throws​

  • \InvalidArgumentException — When an entry is neither, or names no part.

Since: %ver%

Source: src/Schema/UniversalField.php:817

add_input()​

public function add_input( Input $input ): self

Adds one part.

Parameters​

NameTypeDefaultDescription
$inputInputThe part.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:836

get_conditional_logic()​

public function get_conditional_logic(): ?array

When this field appears, in the array form adapters read.

Rules that arrived in a platform's own vocabulary come back exactly as they arrived. Read conditional_logic() for the model's own rules, which are null in that case.

Returns​

  • array | null

Since: %ver%

Source: src/Schema/UniversalField.php:900

conditional_logic()​

public function conditional_logic(): ?UniversalConditionalLogic

When this field appears.

Null when nothing governs it, and also when the rules arrived in a platform's own vocabulary: this model does not guess a translation, so a caller that gets null while has_conditional_logic() is true is holding rules only that platform can read.

Returns​

  • UniversalConditionalLogic | null

Since: %ver%

Source: src/Schema/UniversalField.php:923

has_conditional_logic()​

public function has_conditional_logic(): bool

Whether anything governs when this field appears.

Returns​

  • bool

Since: %ver%

Source: src/Schema/UniversalField.php:934

set_conditional_logic()​

public function set_conditional_logic( $logic ): self

Sets when this field appears.

Takes the rules, and the array adapters hand over. An array already in this model's vocabulary becomes rules; one carrying a platform's own operators is kept exactly as it arrived, because a guessed translation changes which answers show the field.

Parameters​

NameTypeDefaultDescription
$logicUniversalConditionalLogic | array | nullRules, the array form, or null.

Returns​

  • self

Throws​

  • \InvalidArgumentException — When it is none of those.

Since: %ver%

Source: src/Schema/UniversalField.php:953

get_extensions()​

public function get_extensions(): ExtensionData

Gets extensions.

Returns​

  • ExtensionData

Since: %ver%

Source: src/Schema/UniversalField.php:1017

set_extensions()​

public function set_extensions( ExtensionData $extensions ): self

Sets extensions.

Parameters​

NameTypeDefaultDescription
$extensionsExtensionDataExtensions.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:1030

get_transformation_log()​

public function get_transformation_log(): ?TransformationLog

Gets transformation log.

Returns​

  • TransformationLog | null

Since: %ver%

Source: src/Schema/UniversalField.php:1043

set_transformation_log()​

public function set_transformation_log( ?TransformationLog $transformation_log ): self

Sets transformation log.

Parameters​

NameTypeDefaultDescription
$transformation_logTransformationLog | nullTransformationLog.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:1056

get_source_field_ids()​

public function get_source_field_ids(): array

Gets source field IDs.

Returns​

  • array

Since: %ver%

Source: src/Schema/UniversalField.php:1069

set_source_field_ids()​

public function set_source_field_ids( array $source_field_ids ): self

Sets source field IDs.

Parameters​

NameTypeDefaultDescription
$source_field_idsarraySource field IDs.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:1082

is_recomposed()​

public function is_recomposed(): bool

Checks if field was recomposed.

Returns​

  • bool

Since: %ver%

Source: src/Schema/UniversalField.php:1095

set_recomposed()​

public function set_recomposed( bool $is_recomposed ): self

Sets recomposed flag.

Parameters​

NameTypeDefaultDescription
$is_recomposedboolWhether field was recomposed.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:1108

from_array()​

public static function from_array( array $data ): self

Creates from array.

Parameters​

NameTypeDefaultDescription
$dataarrayArray data.

Returns​

  • self

Since: %ver%

Source: src/Schema/UniversalField.php:1123

to_array()​

public function to_array(): array

Converts to array.

Returns​

  • array

Since: %ver%

Source: src/Schema/UniversalField.php:1168