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