Virtual Field

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

Virtual Field

Post by mishanian »

Hi,
I have a table with the following column:

id, name, code

I would like to generate code dynamically as a virtual field and use it in SEARCH

function Row_Rendering()
{
if(id>10){
	$this->code->CurrentValue=1;
}else{
	$this->code->CurrentValue=2;
}

and use Extend Search for searching code=1
is it possible without creating a view as the original concept is too complex?


arbei
User
Posts: 9286

Post by arbei »

You may use Custom Field.


mishanian
User
Posts: 120

Post by mishanian »

Thanks for your response.

can I update it by CurrentValue?

$this->code->CurrentValue=2;

and is it better to use Row_Rendering or Row_Rendered function?


mishanian
User
Posts: 120

Post by mishanian »

I created a Custom Field.
and now it works on Row_Rendering function

function Row_Rendering()
{
if(id>10){
	$this->code->CurrentValue=1;
}else{
	$this->code->CurrentValue=2;
}

Still, when I use ** Extend Search** for code=1 can not find any record


arbei
User
Posts: 9286

Post by arbei »

You should use a SQL expression for the custom field to get the value from the database directly, not by server event, see the example in the docs.


Post Reply