Row_Rendered is one of the famous Server Events in PHPMaker. This event will be called after rendering a record regardless the page that uses it. It is an extremely useful event for conditional formatting, you can do a lot of things with this event, such as changing font color, font styles, row background color, cell background color, and so forth by changing the Table or Fields class properties in the event according to field values.
In addition, you can get also any Fields property values that related to the goal you want to achieve. For example, you want to know what is the selected text in a field which will be presented using a Select Option (ComboBox) control. For this case, you will use ViewValue property. In the other side, you want to know also what is the original value of the selected item in that ComboBox. For the second case, then you should use CurrentValue property. Both of them are resulting the different output value. This is another flexibility features that I love from PHPMaker.
Unfortunately, this flexibility feature can cause the wrong output when you choose the wrong property value. For example, from the example I mentioned earlier, you want to get the original value of the selected item in the ComboBox, but you are using the ViewValue property value which will get the selected item text, and vice versa. It doesn't matter if you are using the Textbox element for displaying a field value, since the values of that both Fields property are the same.
So, in this article, I will show you how you can use the safest way to get the original value of the field. This is very useful if you often use the ComboBox or Radio Button elements for displaying the description of the lookup values of the certain fields.
So here is the solution. You should use DbValue property instead of ViewValue or CurrentValue. As the name said, DbValue is the value that came from the database. So, if you are using ComboBox or Radio Button controls for displaying the description text that derived from the related lookup tables, then try to always use DbValue property to get the original value from the database.
$myValue = $this->YourFieldName->DbValue; // Don't forget to change YourFieldName with yours! echo "The original value from database is: <strong>" . $myValue . "</strong"; // if you want to check the value of ViewValue and CurrentValue properties: echo "<br>ViewValue property: " . $this->YourFieldName->ViewValue; // Don't forget to change YourFieldName with yours! echo "<br>CurrentValue property: " . $this->YourFieldName->CurrentValue; // Don't forget to change YourFieldName with yours!
If you want to show all the Field property values, then execute this code in Row_Rendered event:
var_dump($this->YourFieldName); // Don't forget to change YourFieldName with yours!