Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Update value via function #2703

Open
joeainsworth opened this issue Dec 15, 2023 · 0 comments
Open

Update value via function #2703

joeainsworth opened this issue Dec 15, 2023 · 0 comments
Labels
Type: Enhancement 📈 Enhancement to our codebase

Comments

@joeainsworth
Copy link

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" };
    },
  });
@joeainsworth joeainsworth added the Type: Enhancement 📈 Enhancement to our codebase label Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement 📈 Enhancement to our codebase
Projects
None yet
Development

No branches or pull requests

1 participant