We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36834
    • 25 Posts
    I am using placeholders to populate a form with values and error messages when it doesn’t pass validation. My question is do I have to initialise these place holders eg.
    $modx->setPlaceholder('userName', NULL);
    $modx->setPlaceholder('userNameError', NULL);
    as I would a php variable eg.
    $userName = NULL;
    $userNameError = NULL;
    or does modx treat an unregistered placeholder as if it were NULL.

    Thanks in advance
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: simonp98 at Dec 21, 2009, 12:14 PM

      I am using placeholders to populate a form with values and error messages when it doesn’t pass validation. My question is do I have to initialise these place holders eg.
      $modx->setPlaceholder('userName', NULL);
      $modx->setPlaceholder('userNameError', NULL);
      as I would a php variable eg.
      $userName = NULL;
      $userNameError = NULL;
      or does modx treat an unregistered placeholder as if it were NULL.
      Unregistered placeholders are skipped until parsing is done, and any remaining ones are simply removed at the end. Additionally, if you use $modx->getPlaceholder() on an unregistered placeholder (or with an invalid key), it will return null explicitly in Revolution, though Evolution will trigger a PHP_NOTICE as it does not check if the key exists before trying to access the unknown index in the placeholder array (though this is ignored unless you enable $modx->stopOnNotice in Evo or set your PHP error level to include PHP_NOTICE).