We use visibility component when we want to hide components from form in some situations. This tutorial shows you how to hide component from form by using visibility component and PHP Code. In our example we will hide buttons Edit Product and Delete Product if there is no products in our database.
For this tutorial, you have to login into developer panel of your application.
1. Login into developer panel of application.
2. Click on Pages menu item.
3. Select page pageProduct.
4. Drag and drop Visibility component from all components list to component named buttonEditProduct that is located on table component named dataTableProduct.
5. In dropped visibility component properties, for Data source type property choose PHP Code.
6. Click on Data source PHP 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. If we set attribute status to true, component will be shown, otherwise component will be hidden. Click on Save button.
7. Repeat steps 4, 5 and 6 for component named buttonDeleteProduct.
8. Click on Save changes, go into your application and check out the results.