Skip to content

Issues with field order on form rendering #19

Open
@barbieswimcrew

Description

@barbieswimcrew

Hey guys! I just realized that the order of the fields is not respected when rendering the form with

{{ form_start(form) }}
{{ form_rest(form) }}
{{ form_end(form) }}

The dependent fields are packed at the end instead of at the position where the addDependent method is located in the fluent interface of the form builder.

So for example:

$builder
    // ...
    ->add('fieldOne')
    ->addDependent('depFieldOne', ['fieldOne'], // ...)
    ->add('fieldTwo')
    ->addDependent('depFieldTwo', ['fieldTwo'], // ...)
    // ...

The rendered field order will be:

fieldOne
fieldTwo
depFieldOne
depFieldTwo

Is there a way to get the dependent fields in the correct order? I would expect the order:

fieldOne
depFieldOne
fieldTwo
depFieldTwo

Of course, I could render them in manual order by using {{ form_row(form.<fieldName>) }} but it would be just great if the correct order as defined in the builder would work out of the box ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions