This feature will appear in version 2.8

A special field type that allows you to execute your own PHP code. You can use it, for example, to generate a text template based on a condition. The code can use values from the current and parent records. In addition to the conditions, the code allows you to make a query to the database.

On the "PHP code" tab, enter your code.

To get a value from the current record or from the parent record, use the [field id], for example:

$status = [169];

To output or store values in the database, the value must be assigned to the $output_value variable, for example:

$output_value = 'My Value';

By default, the code is executed when adding/editing a record. In this case, the value from $output_value is stored in the database, and a filter is available for this value. The stored value in the database is available in the $current_field_value variable.

If the "Execute dynamically" option is enabled, the program will output the value from $output_value, but the value is not stored in the database.

The "Debug mode" option displays the generated code for execution and an array of available fields with their values. Debug mode will work if the "Execute dynamically" option is enabled.

MySql query

Using the db_query () function, you can build a query to the required table and select the values you need, for example:

$info_query = db_query("select id from app_entity_35 where field_169=" . $status );
$info = db_fetch_array($info_query);
$id = $info['id'];