Code Monkey home page Code Monkey logo

Comments (4)

michalkleiner avatar michalkleiner commented on August 25, 2024 1

Yeah, that's been like that for some time now and we had users complaining about it as well. Since our validation was usually simple we asked them to populate those required fields and then archive it.

from silverstripe-cms.

kinglozzer avatar kinglozzer commented on August 25, 2024 1

There’s a method in Form called setValidationExemptActions() (or something similar) - do we just need to add the archive action to that?

from silverstripe-cms.

TomOudeRengerink avatar TomOudeRengerink commented on August 25, 2024

There’s a method in Form called setValidationExemptActions() (or something similar) - do we just need to add the archive action to that?

Already tried that... seems that when the archive action kicks in the validationExemptActions array is empty.

from silverstripe-cms.

GuySartorelli avatar GuySartorelli commented on August 25, 2024

$form->setValidationExemptActions([
'restore',
'revert',
'deletefromlive',
'delete',
'unpublish',
'rollback',
'doRollback',
'archive',
]);

CMSMain does this for SiteTree (or, more specifically, does it for the edit form most typically used for SiteTree), which is why this doesn't happen for pages.

DataObject subclasses are most typically edited using a gridfield, which means the form that needs this treatment is the one produced by GridFieldDetailForm_ItemRequest::ItemEditForm().

You should be able to work around this by adding the following extension to GridFieldDetailForm_ItemRequest:

class GridFieldValidationExcemptExtension extends Extension
{
    public function updateItemEditForm(Form $form): void
    {
        $form->setValidationExemptActions([
            'doArchive',
            // You probably want to also add other actions like delete, restore, etc
        ]);
    }
}

Ideally this will be done in core directly in GridFieldDetailForm_ItemRequest::ItemEditForm() through a PR. If someone wants to do that I'd be happy to look at it.

from silverstripe-cms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.