Skip to main content

GravityKit\GravityMigrate\Schema\GfCompositeInputs

Builds the full input set a Gravity Forms composite field expects.

Gravity Forms looks up a composite field's inputs by fixed id and does not check whether they exist: GF_Field_Name reads the prefix input at .2 whether or not a prefix is shown, and GF_Field_Time reads .1 and .2 for its hour and minute labels. Supply only the inputs a form actually uses and those lookups return null: every render emits PHP notices and the sub-labels fall back to defaults that can no longer be edited.

Gravity Forms' own editor always creates the complete set and marks the unused entries hidden (GetAdvancedNameFieldInputs in js.php), which is what these build.

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:24

Details

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

Methods

MethodDescription
address()The six inputs a Gravity Forms address stores its parts in.
visible_name_parts()Which parts of a name field are actually shown.
name()Builds the five inputs a name field expects.
date()The inputs a Gravity Forms date field reads when it is shown as separate boxes.
with_placeholders()Puts a placeholder on the inputs named by id suffix.
time()Builds the three inputs a time field expects.

Method Reference

address()

public static function address( int $field_id ): array

The six inputs a Gravity Forms address stores its parts in.

Read off the field's own renderer, which addresses them positionally: .1 street, .2 line two, .3 city, .4 state, .5 zip, .6 country (includes/fields/class-gf-field-address.php:163-177).

Parameters

NameTypeDefaultDescription
$field_idintGravity Forms field id.

Returns

  • array

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:39

visible_name_parts()

public static function visible_name_parts( array $field ): array

Which parts of a name field are actually shown.

Gravity Forms' nameFormat says whether a name is one box or several, not which several. "advanced" means multi-part, and each part is shown or hidden by its own input's isHidden, which is what the field's own rendering reads (if ( $is_admin || ! rgar( $middle_input, 'isHidden' ) ), class-gf-field-name.php:296). Every ordinary first-and-last name is "advanced" with the prefix, middle and suffix hidden, so reading the format alone and treating "advanced" as all five parts puts boxes on the far side that nobody asked for.

A field carrying no inputs at all is read as first and last, Gravity Forms' own default.

Parameters

NameTypeDefaultDescription
$fieldarrayGravity Forms name field.

Returns

  • string[] — The parts shown, in the order Gravity Forms keeps them.

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:80

name()

public static function name( int $field_id, array $visible=[ 'first', 'last' ], array $labels=[] ): array

Builds the five inputs a name field expects.

Parameters

NameTypeDefaultDescription
$field_idintGravity Forms field id.
$visiblestring[][ 'first', 'last' ]Which parts are shown: prefix, first, middle, last, suffix.
$labelsarray[]Optional part => label overrides.

Returns

  • array

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:122

date()

public static function date( int $field_id, array $placeholders=[] ): array

The inputs a Gravity Forms date field reads when it is shown as separate boxes.

Gravity Forms looks the three up by fixed id, month first, then day, then year (class-gf-field-date.php:230), and reads a placeholder off each of them. A date shown as one picker has no boxes to put wording in, so it is given none.

Parameters

NameTypeDefaultDescription
$field_idintGravity Forms field id.
$placeholdersarray[]Placeholders keyed month, day, year.

Returns

  • array

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:168

with_placeholders()

public static function with_placeholders( array $inputs, array $placeholders ): array

Puts a placeholder on the inputs named by id suffix.

A composite field keeps its wording per part rather than one for the whole field.

Parameters

NameTypeDefaultDescription
$inputsarrayInputs.
$placeholdersarrayPlaceholders keyed by id suffix.

Returns

  • array

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:208

time()

public static function time( int $field_id, bool $is_24_hour=false ): array

Builds the three inputs a time field expects.

The AM/PM input exists on a 24 hour field too, hidden, because Gravity Forms reads it when the format is switched back.

Parameters

NameTypeDefaultDescription
$field_idintGravity Forms field id.
$is_24_hourboolfalseWhether the field uses a 24 hour clock.

Returns

  • array

Since: %ver%

Source: src/Schema/GfCompositeInputs.php:236