A Condition for update records, readonly set

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

A Condition for update records, readonly set

Post by btrade »

Hello,
How can I disable an update for some field when I have something condition?
Edit page ???

if ($this->verrifyt->CurrentValue == 1) {

??????

}

mobhar
User
Posts: 11700

Post by mobhar »

You may try:

if ($this->verrifyt->CurrentValue == 1) {
    $this->YourFieldName->ReadOnly = true;
}

btrade
User
Posts: 357

Post by btrade »

It works
Edit page. - Page_Render()


btrade
User
Posts: 357

Post by btrade »

It doesn't work when I have a Return false

function Row_Updating($rsold, &$rsnew)
{

	if (($rsold['verefy'] == 1) && (!empty($rsnew['malls_id']))) {

		$this->setFailureMessage("error");
		return false;    
	} else {   
		return true;
	}
}

After this message, I have opportunity for the edition all fields.

And don't work when I have cascading selects.

function Page_Render()
{
	
	if ($this->verefy->CurrentValue == 1) {
		$this->city_id->ReadOnly = true; // One for steep I select city. And first step, I select mall  
		$this->malls_id->ReadOnly = true; // It doesn't work 
		$this->store_name->ReadOnly = true;
		$this->phone->ReadOnly = true;
		$this->address->ReadOnly = true;    
	}

}

How can I fix it?


mobhar
User
Posts: 11700

Post by mobhar »

btrade wrote:

After this message, I have opportunity for the edition all fields.

Did you mean if the system return false, then end-users are abel to edit all the fields that already set as ReadOnly in Page_Render server event of Edit page?

btrade wrote:

And don't work when I have cascading selects.

Did you mean Cascading Selects is equal to Dynamic Selection List?


btrade
User
Posts: 357

Post by btrade »

mobhar wrote:

Did you mean if the system return false, then end-users are abel to edit all the fields that already set as ReadOnly in Page_Render server event of Edit page?

Yes, I meant it.

mobhar wrote:

Did you mean Cascading Selects is equal to Dynamic Selection List?

Yes, I meant it. Do I have 2 fields like country and city. Readonly settings are not applied to the city.


mobhar
User
Posts: 11700

Post by mobhar »

When you return false in Row_Updating server event, then you may use a session variable by assigning it a certain flag value to allow edit, for example:

function Row_Updating($rsold, &$rsnew)
{
    if (($rsold['verefy'] == 1) && (!empty($rsnew['malls_id']))) {
        $_SESSION["allow_edit"] = "1"; // <-- when error happened, then allow edit
        $this->setFailureMessage("error");
        return false;    
    } 
    return true;
}

Your code in Page_Load server event:

// Page Load event
function Page_Load()
{
    $_SESSION["allow_edit"] = "0"; // initial condition, do not allow edit
}

Last but not least, your code in Page_Render server event is:

// Page Render event
function Page_Render()
{
    if ($this->verefy->CurrentValue == 1 && isset($_SESSION["allow_edit"]) && $_SESSION["allow_edit"] != "1") {
        $this->city_id->ReadOnly = true;
        $this->malls_id->ReadOnly = true;
        $this->store_name->ReadOnly = true;
        $this->phone->ReadOnly = true;
        $this->address->ReadOnly = true;
    }
}

btrade
User
Posts: 357

Post by btrade »

This method doesn't work. I don't know why.


mobhar
User
Posts: 11700

Post by mobhar »

Which one that does not work? You should always explain it in more detail, so others could comprehend the situation straightforward.


btrade
User
Posts: 357

Post by btrade »

I have added all parts of code. Next i made logout and login. now I see don't work a settings for readonly.
I can update all data this form.


mobhar
User
Posts: 11700

Post by mobhar »

You just need to adjust the code in Page_Render that suits your needs.


btrade
User
Posts: 357

Post by btrade »

it does`t work.

function Page_Render()
{

if ($this->verefy->CurrentValue == 1 && isset($_SESSION["allow_edit"]) && $_SESSION["allow_edit"] != "1") {
        $this->city_id->ReadOnly = true;
        $this->malls_id->ReadOnly = true;
        $this->store_name->ReadOnly = true;
        $this->phone->ReadOnly = true;
        $this->address->ReadOnly = true;
    }
}

it works very well. But if I have returned false, it doesn't work

function Page_Render()
{

if ($this->verefy->CurrentValue == 1) {
        $this->city_id->ReadOnly = true;
        $this->malls_id->ReadOnly = true;
        $this->store_name->ReadOnly = true;
        $this->phone->ReadOnly = true;
        $this->address->ReadOnly = true;
    }
}

Post Reply