8000 [Form] Support event listeners in buttons · Issue #8735 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Form] Support event listeners in buttons #8735
@webmozart

Description

@webmozart

The event POST_SUBMIT (and potentially PRE_SUBMIT, PRE_SET_DATA and POST_SET_DATA) should be supported on buttons. Using this event, dynamic functionality can be built into forms that depends on whether a button was clicked or not:

$builder->get('refresh')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
    $refresh = $event->getForm();
    $form = $refresh->getParent();

    if ($refresh->isClicked()) {
        // do something with $form
    }
});

May be related to #5807.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0