Skip to content

Instantly share code, notes, and snippets.

@alexweissman
Last active August 29, 2015 14:13
Show Gist options
  • Save alexweissman/503f47d375000fb5e549 to your computer and use it in GitHub Desktop.
Save alexweissman/503f47d375000fb5e549 to your computer and use it in GitHub Desktop.
Example loading a dropdown
<?php
$user_choices = [];
if (checkActionPermission('loadUsers', array())) {
if (($users = loadUsers()) === false) {
apiReturnError($ajax, ACCOUNT_ROOT);
}
foreach ($users as $user_id => $user){
$user_choices[$user_id] = $user['display_name'] . " (" . $user['user_name'] . ")";
}
}
$fields = [
"user_dropdown" => [
"type" => "select",
"label" => "Select user",
"display" => 'show',
"icon" => "fa fa-user",
"choices" => $user_choices,
"placeholder" => "Select user",
'validator' => [
'selected' => true,
'label' => 'Select user'
]
]
];
$template = "{{user_dropdown}}";
$fb = new FormBuilder($template, $fields, [], []);
echo $fb->render();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment