avo icon indicating copy to clipboard operation
avo copied to clipboard

Edit `has_one` field in forms

Open adrianthedev opened this issue 1 year ago • 0 comments

Feature

There's a common practice to have a User model that has a has_one association with Profile. Also, there's a common need to be able to edit the profile record on the edit user page.

So we'd like to support that.

Approach

  • we could use accepts_nested_attributes_for because we could offload a lot of functionality on it
  • we need to make sure that the nested fields have their values passed through their own fill_field method before it's passed to the model as a nested attribute
  • we need to render the form for the has_oneon theEdit` view
  • we need to hide the inverse belongs_to association on that form
  • do we need to have a mechanism to hide/sow fields if the resource is nested?

Current workarounds

Using resource tools, but it's a bit cumbersome.

adrianthedev avatar Apr 06 '24 19:04 adrianthedev