We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19119
    • 22 Posts
    Here is a plugin to check fields when you create or edit a document.
    I had the same problem as I had with this plugin : http://modxcms.com/forums/index.php/topic,36409.0.html

    The translation is probably not very good  grin
    //<?php
    /**
    * Required_fields
    * Check if the fields title, longtitle, description and content are not empty
    * The plugin needs to listen OnBeforeDocFormSave event
    * 
    * Created by Guilhem Eydieux, 5th June 2009
    */
    
    $e = & $modx->Event;
    switch ($e->name) {
    	case "OnBeforeDocFormSave":
    		//Uncomment the following line to see what field you can check
    		//die($_POST);
    		
    			$msg = "";
    			if(!isset($_POST["pagetitle"]) || empty($_POST["pagetitle"]))
    				$msg .= "- Title\n";
    			if(!isset($_POST["longtitle"]) || empty($_POST["longtitle"]))
    				$msg .= "- Long title\n";
    			if(!isset($_POST["description"]) || empty($_POST["description"]))
    				$msg .= "- Description\n";
    			if(!isset($_POST["ta"]) || empty($_POST["ta"]))
    				$msg .= "- Content\n";
    			
    			if($msg != "")
    			{
    				$id = intval($_POST['id']);
    				$pid = intval($_POST['parent']);
    				$mode = $_POST['mode'];
    				$url = "index.php?a=$mode" . ($mode == '27' ? "&id=" . $id : "") . ($mode == '4' ? "&pid=" . $pid  : "");
    				$modx->manager->saveFormValues($mode);
    				$modx->webAlert("The following fields are required :\n".$msg,$url);
    				die();
    			}
    		break;
    }
    //?>
    


    I hope it will help people smiley
      • 16183
      • 1,390 Posts
      Thx for sharing... smiley

      /k
        • 7231
        • 4,205 Posts
        Cool idea, this can come in handy. grin
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]