This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 3
Limit Entries per Field
Started 10 years ago by jfurtado | 3 posts |
-
In earlier versions I was able to add custom PHP code to view-functions.php file to query db, count number of entries for a specific field and execute a code depending on the result. That seems to no longer work. Is there an alternative? I understand I can limit entries for the whole form, but I need to do something more specific. In this case we are signing up hundreds of kids for a workshop sessions. Each session has limited of seats, so I need to be able to disable the specific dates that become full.
Thanks for your help!
Posted 10 years ago # -
There are some changes with v4 code and most likely the custom code you are using need to be updated.
Can you let me know the code you added to the view-functions.php file please?MachForm Founder
Posted 10 years ago # -
function mf_display_raw_form($dbh,$form_id) {global $mf_lang;
if ($form_id == 31310) {
$query = "SELECT element_6, count(*) as signedUp2
FROM ap_form_{$form_id} GROUP BY element_6 ASC";
$result = mf_do_query($query,$params,$dbh);while($row = mf_do_fetch_result($result)){
$el_disable_array = array();
foreach ($row as $key => $list) {
if ($key !== "signedUp2") {
$disableElement = $list;
} else {
if ($list >= 16) {
echo '
<script type="text/javascript">
$(document).ready(function() {
$("input#element_6_'.$disableElement.'").attr("disabled", true);
});
</script>';
}
}
}
}
}
Posted 10 years ago #
Reply
You must log in to post.