Friends don't let friends use WordPress...
at least I found one more reason to migrate that content site to SS
On the rare occasion we take over a Wordpress site, we usually gentaly push the owner to convert to SS
Is it possible to distinguish between Saving and Publishing within the
validate() method on a DataObject?
Not sure publishing makes that call. An object must be in a saved state in order to be published.
I suppose you mean what used to be the "Save & publish" button - and I suppose my shot in the dark answer would be "no."
Yup, that's what I mean, and yeah. Was hoping to be able to allow saving a draft even if fields were missing that are required for publishing.
use onBeforePublish which I think is a thing :)
oh! I just did something similar to this for a project
getCMSFields(), I check to see if that object has all of the required fields. If one of them is missing that’s required for it to be published, then I remove the publish button.
in the validate method, I think I was able to check to see if the object is published already, and if it is, then I apply the stricter criteria.
You don't happen to recall how you removed the publish button? Is it part of the
FieldList returned from
hmm… i’ll have to look. give me a sec
oh! I overrode the
canPublish() function, and just return false if any of my “required-to-publish” fields are empty
apparently I only half-remembered how I pulled this off lol
Thanks again. That makes more sense, since I couldn't find the publish button.
Nice. That could work!