Commit bde243b
committed
Fix CondClauseError when using use_parent_field_for_type with matching
types
When using `use_parent_field_for_type` option in `polymorphic_embeds_one`,
the `action_and_struct/4` function's cond block was missing a clause to
handle the case when both `type_from_parent_field` and `type_from_map`
are present and match.
The existing cond only handled:
1. type_from_parent_field is nil -> :type_not_found
2. type_from_map is nil -> get module and return action/struct
3. types don't match -> raise error
This caused a CondClauseError when form params included the `__type__`
field matching the parent field type (e.g., during form validation).
Added a `true` clause to handle the matching types case, which behaves
the same as when type_from_map is nil - it uses the parent field type
to determine the module and returns the appropriate action/struct tuple.1 parent 18a506d commit bde243b
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
363 | 373 | | |
364 | 374 | | |
365 | 375 | | |
| |||
0 commit comments