vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
922 stars 57 forks source link

[autoform] support editing fields for @OneToOne releationships #1540

Open platosha opened 1 year ago

platosha commented 1 year ago

Auto form should inline fields from nested entities referenced with @OneToOne

krissvaa commented 1 year ago

Model with @OneToOne annotation causes exception when used with AutoForm in 2.3.0-beta1 build.

React Router caught the following error during render TypeError: Invalid value used as weak map key at WeakMap.set () at new _M (BinderNode.ts:134:11) at u2 (BinderNode.ts:47:12) at Object.field (index.ts:121:17) at AutoFormIntegerField (autoform-field.tsx:37:44) at renderWithHooks (react-dom.development.js:16305:18) at mountIndeterminateComponent (react-dom.development.js:20074:13) at beginWork (react-dom.development.js:21587:16) at beginWork$1 (react-dom.development.js:27426:14) at performUnitOfWork (react-dom.development.js:26557:12)

Problem in this line when 'propertyInfo.name' is "address.streetAddress" https://github.com/vaadin/hilla/blob/7caea6624c721bc424605b505434c96cd88c33c6/packages/ts/react-crud/src/autoform-field.tsx#L22 It would work with form.model["address"]["streetAddress"]

Either this functionality is added or unsupported for AutoForm, but it shouldn't cause exceptions as using model with nested entities are valid for AutoGrid.

@ Entity @ Table(name = "users") public class User { ... @ OneToOne private Address address; ... }

@ Entity @ Table(name = "addresses") public class Address { ... private String streetAddress; ...