silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
720 stars 820 forks source link

ENH Return PJAX responses from gridfield edit forms #11206

Closed GuySartorelli closed 2 months ago

GuySartorelli commented 2 months ago

Description

Adds a PJAX response negotiator to GridFieldDetailForm_ItemRequest so that javascript which is expecting PJAX responses will get what it's expecting.

Note there's a kitchen sink CI run linked in the main issue

Manual testing steps

  1. Add silverstripe/frameworktest to a project and make sure all of the operations work as expected for companies (which are versioned) and employees (which are not versioned) in "Test ModelAdmin"
  2. Add an elemental area to the Company class (yml config snippet below), add a block with an upload field (e.g silverstripe/elemental-fileblock) and make sure you can upload a file to the block and save with the page save button.
SilverStripe\FrameworkTest\Model\Company:
  extensions:
    - DNADesign\Elemental\Extensions\ElementalAreasExtension
  has_one:
    ElementalArea: 'DNADesign\Elemental\Models\ElementalArea'
  owns:
    - 'ElementalArea'
  cascade_duplicates:
    - 'ElementalArea'

Issues

GuySartorelli commented 2 months ago

Note that while this is being implemented to facilitate fixing a bug, the approach is somewhat more risky in terms of chance of regressions than I feel comfortable with in a patch release - hence targeting 5 instead of 5.2.

GuySartorelli commented 2 months ago

I went with this approach because admin uses PJAX for the form submission and elemental expects a PJAX response in return. It doesn't make a distinction between different admin sections or different contexts for the form, nor should it.