How can I check if the user updated a field value ?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sagmag
User
Posts: 182

How can I check if the user updated a field value ?

Post by sagmag »

I have a field that I don't want to set required because it being required depends on the userlevel and also its being filled depends on userlevel. The userlevel 1 has to give a value and the user 2 doesn't have too. For now I am checking if the user updated the value with :

isset($rsnew['category']) && empty($rsnew['category']) //Checking if the user updated the value and did not leave it empty . Is there any function to check that simply in PHPMaker ?


mobhar
User
Posts: 11741

Post by mobhar »

No need to use isset() function; just use empty() function:

if (CurrentUserLevel() == "1" && empty($rsnew['category'])) {
$this->setFailureMessage("Category cannot be empty.");
return FALSE;
}


sagmag
User
Posts: 182

Post by sagmag »

Thanks, When does PHPMaker remove a field from rsnew then, cause I remember a case where the field I wanted to access was not there, that's why I check with isset.


mobhar
User
Posts: 11741

Post by mobhar »

sagmag wrote:
When does PHPMaker remove a field from rsnew then

$rsnew is only to be used for specific server events, "Row_Inserting", "Row_Inserted", "Row_Updating", "Row_Updated", "Row_UpdateConflict", "Grid_Inserted", and "Grid_Updated". Perhaps you try to use it in a server event other than that. That's why it was not there.


Post Reply