Skip to content
  • Oliver Bartsch's avatar
    [TASK] Allow submitting forms via Modals · e3655fea
    Oliver Bartsch authored and Christian Kuhn's avatar Christian Kuhn committed
    Our Modal implementation already provides a couple
    of actions, executed when the modal is confirmed.
    
    However, previously it was not possible to submit
    a form - execute a POST request. All available
    options (e.g. "href" or "data-uri") always executed
    a GET request.
    
    To improve the Modal, especially for operations,
    e.g. "delete", which should always be executed
    via POST, the Modal component is extended for
    corresponding functionality.
    
    Therefore, the Modal does now automatically
    submits the closest form (if one exists), in
    case the trigger has type=submit set. In case
    a button with type=submit is the trigger but is
    not inside a form element, the "form" attribute
    can be used on the button, to submit an arbitrary
    form in the current document.
    
    Alternatively, it's also possible to set the
    "data-target-form" attribute on the trigger
    element, which does not have to be a button,
    to an arbitrary form identifier in the current
    document.
    
    The new functionality is added at the end to
    prevent any side effect for existing functionality.
    
    As demo, the ext:sys_note "Delete this note" button
    is adapted to execute POST requests to delete a note.
    
    Resolves: #96542
    Releases: main
    Change-Id: I528dc8543e644ee7a0cdb2c8f1918d2ce2951af8
    Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72998
    
    
    Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
    Tested-by: default avatarcore-ci <typo3@b13.com>
    Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
    Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
    Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
    e3655fea