Merge pull request #245 from edewit/issue-230

TextArea is child of controller
This commit is contained in:
mfrances17 2020-12-10 09:10:48 -05:00 committed by GitHub
commit 83825c117b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 26 deletions

View file

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

View file

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

View file

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