In my CMP create processor there are certain situations where I am creating a modx user along with the list item to associate the user to the list item. My logic dictates that I create the user before the list item so I have the newly created user id to associate the item to the user. But I need to determine if there will be errors in the list item creation before I create the user. This all works fine except when there are errors creating the list item.
I am attempting to determine in the
beforeSave() method whether or not there are errors using the
hasErrors value but it always returns true even when there are no errors. According to a similar post, I tried resetting it in initialize like so:
//attempt to clear incorrect hasErrors value
public function initiatize(){
$modx->getService('error','error.modError');
$modx->error->message = null;
}
but it has no effect. Even when the create object is submitted successfully the hasErrors value is still true so I have no way to prevent the user creation before.
I guess my question is what is the purpose of hasErrors if it is always evaluated as true even if there are really no errors?
OR should i create the modx user afterSave()? And if so, are all of the object properties available in aftersave()? My only issue with that is I am passing form values that are only needed in the user profile and those properties are unset in the beforeSave() to prevent errors saving the list item for properties not in the db schema. In that case the values would not be available to the parent::afterSave() and my profile would be incomplete.
TIA