[SOLVED] Disable a button in the Details table based on a field in the Master table |
10/7/2024 5:44:50 AM |
PHPRunner General questions | |
A
alfonso authorDevClub member
In phprunner 10.91 I have a loan system with a table called inventory (with id called inventory_id) and another table called partners (with id called partner_id). The table that relates them is called loans and has the fields inventory_id and partner_id. It also has two fields to control the date. One is the date_pres field that stores the date on which the loan is made and another field called date_dev that stores the date on which the loan is returned. But it would be much better if we could disable the add button when the master table "inventory" had a 1 in the "borrowed" field. Or at least use a sweet alert I try disable inlineadd button in ListPage->Before Display`global $conn; // Consulta para verificar si el artículo ya está prestado // Verifica si el registro existe en la tabla inventario // Si el artículo ya está prestado (prestado = 1), bloquear el préstamo $pageObject->hideItem("inline_add"); } Any idea? Thanks |
|
A
|
alfonso authorDevClub member 10/7/2024 |
See image:
|
![]() |
Sergey Kornilov admin 10/7/2024 |
It is hard to fully understand what you trying to achieve but I can tell you that BeforeDisplay event is not the right place to do so. As you can see in documentation, BeforeDisplay event doesn't provide access to $values array. $values array is usually available in those events that work with a single record while on the List page you have multiple records. More info: |
A
|
alfonso authorDevClub member 10/7/2024 |
I don't know where to put the code so that if in the Master table called inventory a field called borrowed is equal to 1 then in the loans table it doesn't allow adding records |
C
|
cristi 10/9/2024 |
If you don't need the add button for details disabled on the fly then you can use php code in the list page before display of the detail table like this using getMasterRecord(): $master= $pageObject->getMasterRecord(); |
A
|
alfonso authorDevClub member 10/12/2024 |
it works. Thanks |