TextArea doesn't need to be a child of controller

fixes: #230
This commit is contained in:
Erik Jan de Wit 2020-12-04 10:50:35 +01:00
parent 7059297d5f
commit 3f2969e897
3 changed files with 28 additions and 26 deletions

View file

@ -87,7 +87,7 @@ export const ClientSettings = ({ form, save }: ClientSettingsProps) => {
hasNoPaddingTop
>
<Controller
name="alwaysDisplayInConsole"
name="attributes.display_on_consent_screen"
defaultValue={false}
control={form.control}
render={({ onChange, value }) => (
@ -107,7 +107,7 @@ export const ClientSettings = ({ form, save }: ClientSettingsProps) => {
>
<TextArea
id="kc-consent-screen-text"
name="consentText"
name="attributes.consent_screen_text"
ref={form.register}
/>
</FormGroup>

View file

@ -86,6 +86,7 @@ export const FormAccess = ({
children,
} as any);
}
return cloneElement(
child,
child.type === FormGroup ||

View file

@ -16,12 +16,7 @@ import {
ValidatedOptions,
} from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import {
Controller,
SubmitHandler,
useForm,
UseFormMethods,
} from "react-hook-form";
import { SubmitHandler, useForm, UseFormMethods } from "react-hook-form";
import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation";
import { FormAccess } from "../components/form-access/FormAccess";
@ -63,25 +58,31 @@ const RoleForm = ({ form, save, editMode }: RoleFormType) => {
isReadOnly={editMode}
/>
</FormGroup>
<FormGroup label={t("description")} fieldId="kc-description">
<Controller
<FormGroup
label={t("description")}
fieldId="kc-description"
validated={
form.errors.description
? ValidatedOptions.error
: ValidatedOptions.default
}
helperTextInvalid={form.errors.description?.message}
>
<TextArea
name="description"
defaultValue=""
control={form.control}
rules={{ maxLength: 255 }}
render={({ onChange, value }) => (
<TextArea
type="text"
validated={
form.errors.description
? ValidatedOptions.error
: ValidatedOptions.default
}
id="kc-role-description"
value={value}
onChange={onChange}
/>
)}
ref={form.register({
maxLength: {
value: 255,
message: t("common:maxLength", { length: 255 }),
},
})}
type="text"
validated={
form.errors.description
? ValidatedOptions.error
: ValidatedOptions.default
}
id="kc-role-description"
/>
</FormGroup>
<ActionGroup>