Disable edit link in table list

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

Disable edit link in table list

Post by acutri »

v9.2

I would like to disable the edit link for rows that satisfy a condition


acutri
User
Posts: 7

Post by acutri »

my solution:

function ListOptions_Rendered() {

	// Example: 
	if ($this-><DBFIELD>->CurrentValue == <MYVALUE>) { 
		$this->ListOptions->Items["edit"]->Body = "";                
	} 
}                   

thank !!


cduperier
User
Posts: 2

Post by cduperier »

Hi,

I have the same problem. I want to hide the edit button when status = "valide"

This code don't work :

if ($this->status->ViewValue == "valide") {
$this->ListOptions->Items["edit"]->Body = "";
}

danielc
User
Posts: 1601

Post by danielc »

If you put the code into ListOptions_Rendered server event in List Page, it is OK.

Use var_dump($x) to dump your variable to check.


Petr
User
Posts: 16

Post by Petr »

Hi, when I use this working fine, but remove icon is shifted to left.
It`s possible disable this button without this shift or replace to other button?
Regards

Vlastimil


danielc
User
Posts: 1601

Post by danielc »

You need to replace the link rather than empty:
//your condition {
$this->ListOptions->Items["edit"]->Body = "<div><a href='javascript:void(0);'><img ...></a></div>" ; // add your image
// }


Petr
User
Posts: 16

Post by Petr »

Thanks


eudosia
User
Posts: 113

Post by eudosia »

acutri wrote:
my solution:

function ListOptions_Rendered() {

	// Example: 
	if ($this-><DBFIELD>->CurrentValue == <MYVALUE>) { 
		$this->ListOptions->Items["edit"]->Body = "";        
   
	} 
}                   

thank !!

Hello. I am in the list page.
I try to use this statement : $this-><DBFIELD>->CurrentValue
I need It to put in a link to open a custom page like <a href="test.php?id=\"".$this->id->CurrentValue."\">
but the id value is missing. I have put this code into ListOptions_Rendered event.
Do where I'm wrong ?
Thanks.
Max


danielc
User
Posts: 1601

Post by danielc »

eudosia wrote:
$this->id->CurrentValue

If you put this into ListOptions_Rendered server event, there will have value (if id is your ID field)

eudosia wrote:
<a href="test.php?id=\"".$this->id->CurrentValue."\">

Also, just a quick glance, your syntax for href need to correct assume this is what you need to put into body of edit link:
"<a href=\"test.php?id=" . $this->id->CurrentValue . "\"></a>";

Anyway, can you post your complete code so that it is easy for discussion.


eudosia
User
Posts: 113

Post by eudosia »

Thanks so much danielc.
My syntax was wrong...so the link was truncated.....but I fallen in error thanks to the phpmaker editor syntax highlight that tell me my syntax was right.
Now I have correct:
function ListOptions_Rendered() {
// Example:
$this->ListOptions->Items["stampa"]->CssStyle="text-align:center;";
$this->ListOptions->Items["stampa"]->Body = "<a href=\"test.php?id=" . $this->id->CurrentValue . "\" class=\"btn btn-small ewRowLink ewDetailList\">Stampa</a>";


}
but in this case the syntax here $this->ListOptions->Items["stampa"]->Body = "<a href=\"test.php?id=" . $this->id->CurrentValue . "\" class=\"btn btn-small ewRowLink ewDetailList\">Stampa</a>";
appears not correct in the phpmaker10 editor.
THanks so much to point me the mistake.
Max.


SmithCOLE
User
Posts: 1

Post by SmithCOLE »

Hello..
Actually i have some problem with disable edit.Please give me some idea so that i can easily do my work in PHP.


mobhar
User
Posts: 11703

Post by mobhar »

@SmithCOLE,

In which part you have the problem?


Tonygo
User
Posts: 6

Post by Tonygo »

Just to clarify for anyone else, this worked for me in the List page - place under table-specific.
I have a column called Status which has either active or inactive in it and I wanted to hide the edit icon if inactive:

// ListOptions Rendered event
function ListOptions_Rendered() {
if ($this->Status->CurrentValue == "inactive") {
$this->ListOptions->Items["edit"]->Body = "False";
}
}


Post Reply