Page 1 of 1

Custom field Values and Attributes

Posted: Wed Oct 02, 2019 4:06 pm
by philmills

If you want to get or set the properties of a custom field, you cannot use $this-><fieldname>

I hit this issue when trying to add custom field variables to the Row_Rendered function, where the custom fields were at best being ignored, at worst giving me undefined property errors.
I couldn't find anything in documentation about this either.
After digging around the php code for my list page, it turns out that Custom Fields are differentiated with an underscore in front of the field name

In your Row_Rendered scripts you need to use $this->_<fieldname>-><Value or attribute>

so instead of (in the case of a standard field)
$this->MyFieldName->ViewValue ="Some text";

you need to use
$this->_MyFieldName->ViewValue ="Some text";


Re: Custom field Values and Attributes

Posted: Wed Oct 02, 2019 4:25 pm
by arbei

From the help file (the topic Tools > Database, Table and Field Variable Names):

As for table and field variable names, if the table/field name is alphanumeric, the table/field variable name is same as the table/field name. Otherwise, spaces are replaced by underscores, and other non alphanumeric characters are replaced by their hexadecimal string representation of their unicode value. If the variable is a reserved word or starts with a digit, it will be prepended with an underscore. To check the table/field variable names used by the project, you can go the Database pane, right click a table and select Object Properties, you will see the variable names.