Page 1 of 1

Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 9:10 am
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?


Re: Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 9:46 am
by arbei

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


Re: Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 9:51 am
by lissa

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


Re: Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 9:57 am
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.


Re: Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 10:41 am
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=";
}

Re: Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 2:18 pm
by arbei

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


Re: Prefix urlencode(): Passing null to parameter #1

Posted: Mon Sep 02, 2024 2:31 pm
by lissa

thank you, it's working