Skip to main content

GravityKit\GravityMigrate\Schema\GfNormalizer

Fills a Gravity Forms form, field, notification or confirmation out to the shape Gravity Forms

itself expects.

A form built by an adapter carries only what the source platform had. Gravity Forms reads many properties unconditionally, so a field arriving without them raises notices on render or, worse, behaves as though a setting were deliberately off. These defaults are what a form created in the Gravity Forms editor would have.

Since: %ver%

Source: src/Schema/GfNormalizer.php:21

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\Schema

Methods

MethodDescription
get_field_defaults()Returns default properties for a Gravity Forms field type.
get_input_defaults()Returns default properties for field inputs.
get_choice_defaults()Returns default properties for field choices.
get_button_defaults()Returns default properties for form buttons.
get_form_defaults()Returns default properties for a form.
get_notification_defaults()Returns default properties for form notifications.
get_confirmation_defaults()Returns default properties for form confirmations.
normalize_field()Normalizes a single field to include known properties.
flatten_fields()Every field of a form, a repeater's children included, parent before child.
normalize_fields()Normalizes a list of fields.
normalize_button()Normalizes a form button configuration.
normalize_notifications()Normalizes a notification collection.
normalize_confirmations()Normalizes a confirmation collection.
normalize_form()Normalizes a Gravity Forms form payload.
filter_optional_props()Removes empty optional values to avoid overriding defaults.

Method Reference

get_field_defaults()

public static function get_field_defaults( string $type ): array

Returns default properties for a Gravity Forms field type.

Parameters

NameTypeDefaultDescription
$typestringField type.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:32

get_input_defaults()

public static function get_input_defaults(): array

Returns default properties for field inputs.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:50

get_choice_defaults()

public static function get_choice_defaults(): array

Returns default properties for field choices.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:62

get_button_defaults()

public static function get_button_defaults(): array

Returns default properties for form buttons.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:74

get_form_defaults()

public static function get_form_defaults(): array

Returns default properties for a form.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:86

get_notification_defaults()

public static function get_notification_defaults(): array

Returns default properties for form notifications.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:98

get_confirmation_defaults()

public static function get_confirmation_defaults(): array

Returns default properties for form confirmations.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:110

normalize_field()

public static function normalize_field( array $field ): array

Normalizes a single field to include known properties.

Parameters

NameTypeDefaultDescription
$fieldarrayField configuration.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:124

flatten_fields()

public static function flatten_fields( array $fields ): array

Every field of a form, a repeater's children included, parent before child.

Gravity Forms nests the fields of a repeater inside it and the API returns them that way, so anything that walks only the top level counts a sixteen-field repeater as one field. WPForms stores those children as fields of the form in their own right -- its repeater holds only their ids -- so a count taken from the top level alone disagrees with what the destination ends up holding.

Objects and arrays both, because GFAPI::get_form() returns GF_Field objects while a decoded export is arrays.

Parameters

NameTypeDefaultDescription
$fieldsarrayFields, possibly holding nested fields.

Returns

  • array — A flat list, in the order a reader meets them.

Since: %ver%

Source: src/Schema/GfNormalizer.php:322

normalize_fields()

public static function normalize_fields( array $fields ): array

Normalizes a list of fields.

Parameters

NameTypeDefaultDescription
$fieldsarrayField list.

Returns

  • array — Each entry normalized; anything that is not an array is passed through as it arrived.

Since: %ver%

Source: src/Schema/GfNormalizer.php:348

normalize_button()

public static function normalize_button( array $button ): array

Normalizes a form button configuration.

Parameters

NameTypeDefaultDescription
$buttonarrayButton configuration.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:371

normalize_notifications()

public static function normalize_notifications( array $notifications ): array

Normalizes a notification collection.

Parameters

NameTypeDefaultDescription
$notificationsarrayNotification collection.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:385

normalize_confirmations()

public static function normalize_confirmations( array $confirmations ): array

Normalizes a confirmation collection.

Parameters

NameTypeDefaultDescription
$confirmationsarrayConfirmation collection.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:413

normalize_form()

public static function normalize_form( array $form ): array

Normalizes a Gravity Forms form payload.

Parameters

NameTypeDefaultDescription
$formarrayForm payload.

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:441

filter_optional_props()

public static function filter_optional_props( array $props, array $keep_empty_keys=[] ): array

Removes empty optional values to avoid overriding defaults.

Parameters

NameTypeDefaultDescription
$propsarrayOptional properties.
$keep_empty_keysarray[]Keys to keep even when empty, for a setting whose empty value means something other than "unset".

Returns

  • array

Since: %ver%

Source: src/Schema/GfNormalizer.php:476