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,25 +58,31 @@ const RoleForm = ({ form, save, editMode }: RoleFormType) => {
isReadOnly={editMode} isReadOnly={editMode}
/> />
</FormGroup> </FormGroup>
<FormGroup label={t("description")} fieldId="kc-description"> <FormGroup
<Controller label={t("description")}
fieldId="kc-description"
validated={
form.errors.description
? ValidatedOptions.error
: ValidatedOptions.default
}
helperTextInvalid={form.errors.description?.message}
>
<TextArea
name="description" name="description"
defaultValue="" ref={form.register({
control={form.control} maxLength: {
rules={{ maxLength: 255 }} value: 255,
render={({ onChange, value }) => ( message: t("common:maxLength", { length: 255 }),
<TextArea },
type="text" })}
validated={ type="text"
form.errors.description validated={
? ValidatedOptions.error form.errors.description
: ValidatedOptions.default ? ValidatedOptions.error
} : ValidatedOptions.default
id="kc-role-description" }
value={value} id="kc-role-description"
onChange={onChange}
/>
)}
/> />
</FormGroup> </FormGroup>
<ActionGroup> <ActionGroup>