How to execute PHP code in action

This tutorial shows you how to execute PHP code in action component. In our example we will use PHP code in action to insert new promotion in our database.

Action sql

1. Login into developer panel of application.

2. Click on Pages menu item.

3. Select page pagePromotions.

4. Drag and drop Action component from all components list to button for registration named ButtonSaveNewPromotions.

Action php code

5. In dropped action component properties, for Action type property choose PHP Code. Click on Action code text field and enter your PHP code. Variable result is an instance of AjaxProxy class. This variable is already instantiated. Attribute status of result variable ($result->status) can be true or false. At the end of your PHP code, attribute status should be set to true. Click on Save button.

PHP for action

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