Prefix urlencode(): Passing null to parameter #1

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

Prefix urlencode(): Passing null to parameter #1

Post by lissa »

Hi Master,

I want to ask about the prefix on the view tag,

vieworderlist?id_order={$this->urlEncode($this->id_order->CurrentValue)}&id=

previously my code ran well, but after I updated the template I encountered an error like this,

ErrorException (E_DEPRECATED)
urlencode(): Passing null to parameter #1 ($string) of type string is deprecated

can anyone tell me if there is a code change that I don't know about?


arbei
User
Posts: 9787

Post by arbei »

PHP 8 does not allow passing null to urlencode, you should check if $this->id_order->CurrentValue has value first.


lissa
User
Posts: 73

Post by lissa »

how to check whether it has value or not?
where do i put this code?
if (!empty($this->id_order->CurrentValue )


arbei
User
Posts: 9787

Post by arbei »

If your prefix cannot be written as inline code, you better use Row_Rendered server event to set the HrefValue property of the field.


lissa
User
Posts: 73

Post by lissa »

i use this code still not working
any suggestions?

if (!empty($this->id_barang->CurrentValue)) {
$this->id_order->HrefValue = "vieworderlist?id_order={". $this->urlEncode($this->id_order->CurrentValue) ."}&id=";
}

arbei
User
Posts: 9787

Post by arbei »

In server event you don't need "{" and "}" anymore, those are for PHP string variable parsing only.


lissa
User
Posts: 73

Post by lissa »

thank you, it's working


Post Reply