CreateImageWizard: fix validation for activation keys
The validators are passed values by the useFieldApi hook. Adding this to the activation key component allows the `required` validation to work.
This commit is contained in:
parent
fa7b0ca553
commit
787b0180de
2 changed files with 8 additions and 4 deletions
|
|
@ -2,10 +2,12 @@ import React, { useEffect, useState } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { FormGroup, Spinner, Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
||||
import useFormApi from '@data-driven-forms/react-form-renderer/use-form-api';
|
||||
import useFieldApi from '@data-driven-forms/react-form-renderer/use-field-api';
|
||||
import api from '../../../api';
|
||||
|
||||
const ActivationKeys = ({ label, isRequired }) => {
|
||||
const ActivationKeys = ({ label, isRequired, ...props }) => {
|
||||
const { change, getState } = useFormApi();
|
||||
const { input } = useFieldApi(props);
|
||||
const [ activationKeys, setActivationKeys ] = useState([]);
|
||||
const [ isOpen, setIsOpen ] = useState(false);
|
||||
const [ isLoading, setIsLoading ] = useState(false);
|
||||
|
|
@ -23,12 +25,12 @@ const ActivationKeys = ({ label, isRequired }) => {
|
|||
const setActivationKey = (_, selection) => {
|
||||
selectActivationKey(selection);
|
||||
setIsOpen(false);
|
||||
change('subscription-activation-key', selection);
|
||||
change(input.name, selection);
|
||||
};
|
||||
|
||||
const handleClear = () => {
|
||||
selectActivationKey();
|
||||
change('subscription-activation-key', undefined);
|
||||
change(input.name, undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue