Skip to content

Commit 4605d83

Browse files
max-moserzzacharopalkerecsenyi
committed
field-components: warn about fields that are both required and disabled
* previously, an error was raised in this case * this broke edit forms where fields were marked as "create only" (and thus disabled on edit) * according to the HTML spec, disabled fields are skipped during validation: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls%3A-the-disabled-attribute Co-authored-by: Zacharias Zacharodimos <[email protected]> Co-authored-by: Pal Kerecsenyi <[email protected]>
1 parent 983ed0d commit 4605d83

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/forms/fieldComponents.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const fieldCommonProps = {
3737
const showHideComponent = (Component, id) => {
3838
const ShowHideComponent = ({ hidden, ...props }) => {
3939
if (props.disabled && props.required) {
40-
throw new Error(`Cannot make field component ${id} both required and disabled`);
40+
console.warn(
41+
`Field component ${id} is marked as required but also disabled, so it is omitted from HTML constraint validation.`
42+
);
4143
}
4244
if (hidden) return null;
4345
return <Component {...props} />;

0 commit comments

Comments
 (0)