1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

List Module - php-events onDelete

Discussion in 'Community' started by joomlamate, Jun 29, 2020.

  1. joomlamate

    joomlamate Member

    Level: Community
    I display a list module inside the details page of another list/form.

    I am trying to run some code using the List PHP Events plugin - onDelete Hook - to delete records on other tables when a Row of the above list is deleted through the module (using the delete button on the right of each row).

    But there, the $model->rowsToDelete is always empty. -Well not always empty. Sometimes it is, others it is not, and I can't say for sure, when it is happening and when it's not, and this has totally baffled me.
    How can I make sure I am reaching the "rowsToDelete" of that list inside my module?

    I suspect the fact that the module exists inside the details of another list/form might be the issue here.
    I have tried with both Ajaxified module and without it among other things (which I don't remember to mention all here, as I am fighting with this for some days now.

    Any input or other ideas would be highly appreciated!
    Last edited: Jun 29, 2020
  2. Nagtegaal

    Nagtegaal Member

    Level: Community
    Hi Joomlamate, my suggestion would be to use a delete statement in the database, which you can be triggered onDeleteRows.

    There should be a correlation between the lists though, which you should use in the where clause. There are some examples in this wiki, e.g. the Update uses the rowid. http://fabrikar.com/forums/index.php?wiki/php-common-tasks/

    Hope this helps.
  3. joomlamate

    joomlamate Member

    Level: Community
    I wrote the post just before leaving the office, after long struggling with the issue. Now that I read it, I realize it was not complete... so I added a bit extra info.
    Also, when I say sometimes the $model->rowsToDelete works and others is not... I mean that:
    After posting here and returning about 1 hour later, with no changes at all in my setup, the $model->rowsToDelete was working and contained data.
    Everything the same, the exact same routine, the same code: 1 hour ago was returning nothing (empty arrays), then it returned the row that was about to delete.

    I started experimenting on a 100% SQL solution with relationships and CASCADE as I don't feel 100% certain that the Fabrik approach will keep working.

    @Nagtegaal - not what I was looking for, but thanks anyway for taking the time to respond. I appreciate it.
  4. joomlamate

    joomlamate Member

    Level: Community
    I ended up implementing the SQL solution

Share This Page