Return Pb in PHP validation plugin

Thanks Cheesegrits for answering :)
Code:
Can you paste your WHERE filter code here?
The code is my 1st post. My query is :
$query = "SELECT count(*) FROM ContactsParams WHERE ID=" . $IDinput;
$IDinput is got from the Form ContactsFormID field :
$IDinput = (int) $formModel->_formData['contacts___ContactsFormID'];
Problem is :
  • that the form value is correctly got when clicking on 'Save' button,
  • but not systematically initialised in the form (cf. my 18th post)
 
WHY IT'S A BUG :
To be sure it's not a PHP function return test problem, when executing the query with $found = (int) $db->LoadResult();
I changed my validation code to :
PHP:
return (($found == 1) ? true : false);
to be sure my return value is always true or false...

To be sure of the execution, I removed J!Dump and use a basic trace, following your recommendations :
Code:
echo "return : ".(($found == 1) ? true : false); exit;
Firebug showed me PERFECT returns code according to all the case I posted in my 18th post.
Removing the trace for normal return, the bug is still there :mad:

BECAUSE I think it's a submission problem, I change the global FORM parameters to 'Ajax validation = YES'
THEN (not using the 'SAVE' form button) each time I change ContactsFormID values, the validation are always perfectly working !!!

Please can you have a look on this weird problem ?
Thanks a lot
Regards
 
I am completely confused by this last post, can you provide full step by step instructions as to what is is you are doing in a single clear post ?
 
I understand. My code is now
PHP:
// Check if ID exists
//===================
// Get the form field's value :
$IDinput = (int) '{contacts___ContactsFormID}';
 
// Get the db object
$db =JFactory::getDbo();
 
// Quote the values for security reasons
$IDinput = $db->quote($IDinput);
 
// Build the query ? Tables names = CASE SENSITIVES
$query = $db->getQuery(true);
$query = "SELECT count(*) FROM contactsparams WHERE ID=" . $IDinput;
$db->setQuery($query);
 
// Run the query
$found = (int) $db->LoadResult();
 
//echo "return : ".(($found == 1) ? true : false); exit;
 
return (($found == 1) ? true : false);

Use case :
With a direct invocation to index.php?option=com_fabrik&view=form&formid=4
it perfectly works when I fill good or wrong values for ContactsFormID
==> so the problem is not in my code or SQL.

BUT invoking the Menu link --> a Joomla article with content plugin invocation with {fabrik view=form id=4 contacts___ContactsFormID=1 show-title=0} I have a weird behavior.
Could it be a Content Plugin problem ???
  • First click on the Menu 'Nous contacter' : ContactsFormID is initialised to 1 (OK)
  • Change ContactsFormID to 2. Validate :
    • ContactsFormID field is validated OK
    • Form is validated KO : normal because other fields are not filled.
    • A Global Form Error message is displayed
  • 2nd click on the Menu 'Nous contacter' : ContactsFormID stays to 2 (KO)
    • 1) Form initialisation is not good
    • 2) Global Form Error message remains on the form
  • 3rd click on the Menu 'Nous contacter' : ContactsFormID is set to 1 (OK)
    • The Global Form Error message dissapears
  • Change ContactsFormID to 4. Validate :
    • ContactsFormID field is validated KO
    • Form is validated KO : normal because other fields are not filled.
    • A Global Form Error message is displayed
  • 4th click on the Menu 'Nous contacter' : ContactsFormID is set to 2 (KO)
    • Form initialisation is not good
    • Global Error message remains on the form
  • 5th click on the Menu 'Nous contacter' : ContactsFormID is set to 1 (OK)
    • Global Error message dissapears
Thanks for help !
 
Still pretty confused I'm afraid, how does what you are describing relate to the PHP validaiton code? I can see that contactsparams has stored records where id = 1 and where id = 2, so in either case if that is the only validation then its going to pass.
I think what you are seeing is in fact an artifact of the way we store the form's state when rendering as a content plugin - I don't see that you need to do that in this case, simply linking to the form and setting the contactFormID's element default to 1 would be sufficient.
 
I started this code to test the validation mechanism on existing criterias (ID = 1 or 2).
1) Do you confirm that my return code would be a good for my other scripts ?
2) hope that real validations won't give other problems.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top