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

Problem with PHP form plugins not submitting

Discussion in 'Professional Support' started by juuser, Jan 12, 2015.

  1. juuser

    juuser Well-Known Member

    Level: Community
    Hi Hugh,

    Thanks for digging in to this issue. Unfortunately i'm still stuck. I changed the element name in the code (from vormi_id to vormi_id_nr), but for some reason i get var_dump only from second plugin. I commented out var_dump lines, but still neither of the plugins seem to execute :(

    BR,
    Martin
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I shall go take another look.

    -- hugh
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    OK, I've rewritten all of your queries using the query builder, added a bunch of debug output, and run an edit and a new (the second plugin is set to only run on new), and as far as I can tell, it's working. Although you may need to check the queries in in the second half of plugin 1, that do the updating.

    And really, that's as much time as I can spend on this for a Standard sub!

    -- hugh
     
  4. juuser

    juuser Well-Known Member

    Level: Community
    Thanks, I really appreciate you spent so much time on this. When I'm starting to get some income from my site, I'm probably going to upgrade to pro.

    As I still didn't get the first plugin to work, I spent some more time for investigation. I think i tracked down the problem. I removed "if" parts of the code and just left one update query that just updates one field in my table. When adding new record, record in database is not updated, although plugin is set to update on both. When editing the record, element data is updated like it should.

    So it seems not to be a problem in the code itself. I know you have spent already a lot of time on this, but do you have any more clues how to solve this issue?

    Thanks :)
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Have you tried uncommenting the var_dump($sql) line on new, and see what the query looks like?

    -- hugh
     
  6. juuser

    juuser Well-Known Member

    Level: Community
    Hi, unfortunately uncommenting didn't help on new record. I mean that when adding new record, no var_dump output is displayed. When editing record, there is var_dump displayed and the output is correct.

    So, generally, when editing record, plugin is processed normally and everything is ok. When adding new record, it's like the plugin doesn't exists at all (no database update, no var_dump output).

    BR,
    Martin
     
  7. rob

    rob Administrator Staff Member

    Level: Community
    Did you set the plugins' "on" option to be "both" - e.g. to run on a save and on an edit?
     
  8. juuser

    juuser Well-Known Member

    Level: Community
    Hi Rob!

    Yes, plugin is set to update on both.

    BR,
    Martin
     
  9. rob

    rob Administrator Staff Member

    Level: Community
    I tried a really simple test case of just inserting two records in a db and that worked fine for me:
    Not sure what else to suggest. - :(
     
  10. troester

    troester Well-Known Member Staff Member

    Level: Community
    This sounds like a php error (do you have Joomla error reporting set to max?)
    Check if your code contains e.g. a unquoted {rowid} - which would be empty in case of a new record, so something like
    $x ={rowid};
    will do in existing records but break in new ones, it must be
    $x ='{rowid}';
     
  11. juuser

    juuser Well-Known Member

    Level: Community
    Thanks for the ideas. I'm starting to go grazy on this. I set Jooma error reporting to maximum and there is no error when adding new record to table. It just ignores the plugin. As you can see, there is var_dump in my code which executes fine on record edit, but it is ignored on new (as it seems the plugin is totally ignored). Here is my plugin code:

    Code (Text):
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
     
          $query->update('prefix_tooted_vormid AS a')
            ->join('LEFT', 'prefix_tooted_vormiremont AS b ON a.id = b.vormi_id_nr')
            ->set("hooldusstaatus='0'")
            ->where("a.id = '{prefix_tooted_vormiremont___vormi_id_nr_raw}'");
     
     
          $sql = (string)$query;
     
          var_dump($sql);exit;
     
     
          $db->setQuery($query);
          return $db->execute();
    There should be no unquoted placeholders and Troester succested.

    BR,
    Martin
     
  12. troester

    troester Well-Known Member Staff Member

    Level: Community
    And the code in your other plugin?
    BTW: I tried to login in "your-site" but alway get an error about log file
     
  13. juuser

    juuser Well-Known Member

    Level: Community
    Other plugin code is:

    Code (Text):
    $tulemus11 = "R";
    $tulemus11 .= "{prefix_tooted_vormiremont___id_raw}";
     
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->update('prefix_tooted_vormiremont')
      ->set('t66_id_nr = ' . $db->quote($tulemus11))
      ->where('id = ' . $db->quote('{prefix_tooted_vormiremont___id_raw}'));
    //$sql = (string)$query7;var_dump($sql);exit;
    $db->setQuery($query);
    return $db->execute();
    I will check the login problem...
     
  14. juuser

    juuser Well-Known Member

    Level: Community
    I can login with these credentials just fine, but i changed log file path in my Joomla configuration file. Hope it's ok now.
     
  15. troester

    troester Well-Known Member Staff Member

    Level: Community
    I think this is the problem:
    you can't update because id_raw doesn't exist on new records.

    So it's no php error but the execute is returning false and - as Hugh said in some earlier post - you should not return the result of $db->execute; if the plugin is returning false this will stop form submission (an so the 2nd plugin)

    So
    1. don't execute the quere if id is empty
    2. don't return the query result in any case
     
  16. juuser

    juuser Well-Known Member

    Level: Community
    Thanks. I'm using second plugin to create work task id from letter R and rowid. Should'nt the row id exists already onAfterProcess?

    And when disabling another plugins, this works just fine.

    Could you be more specific about point 2.
     
  17. juuser

    juuser Well-Known Member

    Level: Community
    I now removed all the code from both plugins and replaced with:

    $mydata = "plugin1";
    var_dump($mydata);
    exit;

    and

    $mydata = "plugin2";
    var_dump($mydata);

    I get var_dump output just from plugin 1, it's like plugin 2 wouldn't exist at all.
     
  18. troester

    troester Well-Known Member Staff Member

    Level: Community
    If there's an exit it will stop execution.

    gesendet mit Tapatalk
     
  19. juuser

    juuser Well-Known Member

    Level: Community
    OK. I understood from Hugh's earlier post that i can get var_dump output from all the plugins if only the last one has exit; row. Anyway i'm totally frustrated and have no idea what else to try.

    I thought to build all the tables (main and several copies) from the scratch, but i'm afraid the problem will still appear after i have made several hours of work ;(
     
  20. juuser

    juuser Well-Known Member

    Level: Community
    ...just upgraded to pro, if that helps :)
     

Share This Page