Skip to content

Commit

Permalink
fix: ensure EmailField inputs are hydrated when Email Confirmation …
Browse files Browse the repository at this point in the history
…is disabled. (#394)
  • Loading branch information
justlevine authored Feb 3, 2024
1 parent 74569d8 commit 486d9b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- fix: Ensure `EmailField` inputs are hydrated when Email Confirmation is disabled. H/t @
Gytjarek.

## v0.12.4

This _minor_ release fixes a bug where updating the plugin via the WordPress backend would fail due to changes to GitHub's API.
Expand Down
19 changes: 17 additions & 2 deletions src/Type/WPInterface/FieldWithInputs.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,26 @@ public static function get_fields(): array {
'inputs' => [
'type' => [ 'list_of' => FieldInput::$type ],
'description' => __( 'The inputs for the field.', 'wp-graphql-gravity-forms' ),
'resolve' => static function ( $source, array $args, AppContext $context, $info ) {
'resolve' => static function ( $source, array $args, AppContext $context ) {
// Email fields without confirmation need to be coerced as an input.
if ( $source instanceof \GF_Field_Email && ! $source->emailConfirmEnabled ) {
$source->inputs = [
[
'autocompleteAttribute' => $source->autocompleteAttribute ?? null,
'defaultValue' => $source->defaultValue ?? null,
'customLabel' => $source->customLabel ?? null,
'id' => $source->id ?? null,
'label' => $source->label ?? null,
'name' => $source->inputName ?? null,
'placeholder' => $source->placeholder ?? null,
],
];
}

/** @var \GF_Field $source */
$context->gfField = $source;

return ! empty( $source->inputs )
return isset( $source->inputs )
// Include GraphQL Type in resolver.
? array_map(
static function ( $choice ) use ( $source ) {
Expand Down

0 comments on commit 486d9b3

Please sign in to comment.