Skip to content

How access to form.parent when the form has child called parent? #18882

Closed
@rafrsr

Description

@rafrsr

How can know if a form has a parent or not, in a view?

The fast answer is:

{{ form.parent }}

but if the form has a child called parent the above statement always return a result, even when they do not have a real parent.

then the only way to know if has a real parent is something like:

{% set hasParent = (form.parent is not null and (not form.offsetExists('parent') or form.parent != form.offsetGet('parent'))) %}

I'm missing something?

a method hasParent() is needed in the FormView to avoid the \ArrayAccess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureFormGood first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions