How to use PHP code data source in selection components

This tutorial shows you how to use PHP code as Data source type in selection component. In our example we have form for adding/editing product. Product has Product category attribute, so we will show selection component on this form that is using PHP code as Data source type.

Singleselect example

1. Login into developer panel.

2. Navigate to Pages menu item.

3. Select page pageProduct.

4. Drag and drop Singleselect component from all components list to formEditProduct. 

Singleselect with php

5. In component properties section, select PHP code as Data source type. Click on textarea under Data source PHP label and enter PHP code. Variable result is an instance of AjaxProxy class. This variable is already instantiated. Attribute data of result variable ($result->data) must be an array with data array key. Click on Save button.

PHP code

6. Click on Save changes, go into your application and check out the results.