I needed to have a list of all (published) forms. I ended up with the following function.
It simply returns an array where the key is the formId while value is the form label.
Anyone has a better way to do this?
function GetForms($onlyPublished = true) {
// init vars
$result = false;
$join = '';
$where = '';
// create where statement based on publish state
if ($onlyPublished) {
$where = "status = 'publish'";
}
// get forms
$wsForm = new \WS_Form_Form($join, $where);
$forms = $wsForm->db_read_all();
// create array based on forms
if (is_array($forms)) {
foreach ($forms as $form) {
$result[$form['id']] = $form['label'];
}
}
return $result;
}