This isn’t Ajaxified or very elegant, but it does the trick:
<?php
/*
"required fields" plugin
=========================
check event "OnBeforeDocFormSave" in configuration tab
plugin code:
include_once $modx->config['base_path'] . 'assets/plugins/required.php';
*/
if (IN_MANAGER_MODE != "true") {
die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
}
$back = "<br /><br /><a href=\"javascript: history.go(-1);\">back</a>";
$e = & $modx->Event;
switch($e->name) {
case "OnBeforeDocFormSave":
$pagetitle = mysql_escape_string($_POST['pagetitle']);
$alias = mysql_escape_string($_POST['alias']);
if(empty($alias)) {
die("The alias field is mandatory! $back");
}
if(empty($pagetitle)) {
die("The page-title field is mandatory! $back");
}
break;
default:
break;
}
?>
^ this only checks pagetitle and alias fields.
This could be vastly improved if you added some config settings at the top, e.g. list of required fields, list of documents etc. But if you need to set this globally for every doc in your modx site, it’s OK I guess.
With JS you could of course add some über-cool CSS field-highlighting, so you see which field is empty (e.g. change bg-color or add a red border), but I’m kinda lazy today
// edit: I just realized this is a ManagerManager discussion. Sorry. The above is not in any way linked to MM. I don’t know how or if you could include it into MM.