Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Update value via function #2703

Description

@joeainsworth

Overview

...

Motivation

Want to use App Bridge UI Resource Picker with useField().

I am trying to use the Resource Picker (which opens via button click) to obtain a product ID.

I'd then like the value to be set against a form input.

Setting configuration.objectRequired.value does not store the state.

  const {
    fields: {
      discountTitle,
      ...
      configuration
    },
    submit,
  } = useForm({
    fields: {
      discountTitle: useField(''),
      ...
      configuration: {
        objectType: useField(''),
        objectRequired: useField(''),
        gwpProduct: useField(''),
      }
    },
    onSubmit: async (form) => {
      const discount = {
        title: form.discountTitle,
        ...
        configuration: {
          objectType: configuration.objectType,
          objectRequired: configuration.objectRequired,
          gwpProduct: configuration.gwpProduct,
        },
      };

      submitForm({ discount: JSON.stringify(discount) }, { method: "post" });

      return { status: "success" };
    },
  });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions