I use this code to redirect visitors to another url when a certain amount of people have subscribed my form:
This works fine. But is there a possibility to disable a specified field (e.g. 'datum') in my form instead of redirecting to another url?
I found this code from Bob:
But I don't understand on how to do so.
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__my_table` ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count >= 15 ) {
// Redirect to my url
$app =& JFactory::getApplication();
$app->redirect('my_url');
}
?>
This works fine. But is there a possibility to disable a specified field (e.g. 'datum') in my form instead of redirecting to another url?
I found this code from Bob:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT
FROM `#__some_table`
WHERE `course_id` = 'xxx' ;
";
$db->setQuery($query);
$count = $db->loadResult();
$form->data['open'] = false;
If ( $count < 999 ) {
$form->data['open'] = true;
}
?>
Then you can use $form->data['open'] to manage the form display.
But I don't understand on how to do so.