#Signal forms - Retrieve parent of a field?

1 messages · Page 1 of 1 (latest)

mild galleon
#

Consider the following form and directive:

form = form(signal({ name: '' }));
@Directive({
  selector: "myDirective"
})
export class MyDirective {
  #field = inject(Field);

  constructor() {
     // how to get the field's parent?
  }
}
<form>
  <input [field]="form.name" myDirective type="text" placeholder="Name" >
</form>

Is it currently possible with signal forms to retrieve the parent of a field? Or do I need to figure out an alternative approach? This is a silly example but I think it demonstrates the problem I am facing.

Thank you for any help!

nocturne field
#

You currently can not get a parent of a field, and that's pretty much intentional

#

But we're looking for strong use cases

mild galleon
#

@nocturne field Okay thanks. I can try and mock up a use case this afternoon.

#

Do you recall the specific reason(s) as to why that is intentional?

nocturne field
#

we couldn't come up with a compelling reason to do that