Hi, sure, no worries. I am just doing a large update for ContentBuilder and I am therefore much slower as I should. Sorry for that.
I attached you a completely working form that showcases how it works. You can build upon it it. Make sure to download, unzip and install in BF => Configuration => Package Installer.
The trick is basically having a custom validation on the firstname (could also be just the lastname) that calls the form for checks on the database state:
function ff_firstname_validation(element, message)
{
JQuery.ajaxSetup({
async: false
});
let result = null;
JQuery.getJSON( '<?php return JUri::root(true)?>/index.php?option=com_breezingforms&ff_form=<?php return intval($_REQUEST["ff_form"]) ?>&checkAjax=1&firstname='+encodeURIComponent(ff_getElementByName('firstname').value) + '&lastname='+encodeURIComponent(ff_getElementByName('lastname').value), function( data ) {
result = data;
});
return result === true ? message : '';
}
Then in form => advanced => more options => form pieces => before form => there is the actual server-side code that returns the state of the database to the calling validation above:
if(isset($_REQUEST['checkAjax']) && $_REQUEST['checkAjax'] == '1' && isset($_REQUEST['firstname']) && isset($_REQUEST['lastname'])){
$handlers = ob_list_handlers();
while (count($handlers) > 0 && $handlers[count($handlers) - 1] != 'ob_gzhandler' && $handlers[count($handlers) - 1] != 'zlib output compression') {
ob_end_clean();
$handlers = ob_list_handlers();
}
header("Content-Type: application/json");
$records = array();
$db = BFFactory::getDbo();
$db->setQuery("Select * From #__facileforms_elements Where form = " . $db->quote(intval($_REQUEST['ff_form'])));
$rows = $db->loadObjectList();
$cnt = count($rows);
for($i = 0; $i < $cnt; $i++)
{
$db->setQuery("Select * From #__facileforms_subrecords Where name = 'firstname' And value = " . $db->quote($_REQUEST['firstname']));
$sub = $db->loadObject();
if($sub)
{
$db->setQuery("Select * From #__facileforms_subrecords Where name = 'lastname' And value = " . $db->quote($_REQUEST['lastname']));
$sub2 = $db->loadObject();
if($sub2)
{
echo 'true';
exit;
}
}
}
echo 'false';
exit;
}
Since this is tested on Joomla4, please replace "BFFactory" above with "JFactory" if you run this on Joomla3 after installation of the form.
This way everything is nicely self-contained and can be adjusted for custom needs.
Regards,
Markus