Skip to content

Instantly share code, notes, and snippets.

@masonjo
Created February 1, 2022 23:49
Show Gist options
  • Save masonjo/50e3cffd2be2d582527f802eafdae637 to your computer and use it in GitHub Desktop.
Save masonjo/50e3cffd2be2d582527f802eafdae637 to your computer and use it in GitHub Desktop.
Line 3 - Notice form-horizontal class Line 13 - options horizontal Line 17 - set the default values and options Choices for select items can be done earlier or right before items. This example has two columns
<div class="well" >
<form action="" method="POST" role="form" >
<div class="row form-horizontal" >
<div class="col-md-6" >
<?php
$sql = "select * from practice where ID=$practice_id";
$form_values1 = ORM::for_table('dummy')->raw_query($sql)->find_array();
$form_values = $form_values1[0];
$fv = fetch1("select firstVisit,gocardconnect from upgrade where practice_id=$practice_id");
$form_values['firstVisit'] = $fv['firstVisit'];
$form_values['gocardconnect'] = $fv['gocardconnect'];
$alertEmails['choices'] = ['contact' => 'Contact Email', 'arcemail' => 'Default Email'];
$options['horizontal'] = true;
$tft['choices'] = ['true' => 'True', 'false' => 'False'];
$lrs['choices'] = ['want' => 'Want', 'started' => 'Started', 'ready' => "Ready", 'active' => 'Active', 'false' => 'False'];
$timezoneList['choices'] = ['PST' => 'Pacific Time', 'EST' => 'Eastern Time', 'CST' => "Central Time ", 'MST' => 'Mountain Time', 'HST' => 'Hawaii Time'];
$form = new bootstrapform($form_values, $options);
$form->submitted('process_form');
$form->addElement('hidden', 'ID');
$form->addElement('text', 'Name', 'Practice Name:');
$gplus['choices'] = ['Unknown' => 'Unknown', '[email protected]' => 'Gplus', '[email protected]' => 'Gplus2', '[email protected]' => 'Gplus3'];
$form->addElement('select', 'gplus_account', 'Gplus Account:', $gplus);
$form->addElement('textarea', 'wmt', 'WMT Tag:');
?>
</div >
<div class="col-md-6" >
<?php
$admins = $db->getAll("Select sec_id,full_name from security where group_id='admin' order by sec_id");
$owners['choices'][0] = "Not Set";
foreach ($admins as $admin) {
$owners['choices'][$admin[0]] = $admin[1];
}
$form->addElement('radio', 'need_setup', 'Self Setup Needed:', $tft);
$form->addElement('text', 'oldlinknumber', 'Old Link ID:');
if ($fv['firstVisit'] > 170239381) {
echo "<h4 class='text-center'>Custom First Visit Video</h4>";
} else {
$firstVid['choices'] = ['No Info' => 'Original', '169285652' => 'New - Men', '170236462' => 'New - Women', '170237203' => 'New - Female Dr, Older Woman Patient', '170237477' => 'New - Male Dr, Older Woman Patient', '170236933' => 'New - Male Dr, Older Male Patient'];
$form->addElement('select', 'firstVisit', 'First Visit Video:', $firstVid);
}
$form->addElement('select', 'timezone', 'Time Zone:', $timezoneList);
// $form->showfields();
?>
</div >
</div >
<div class="row" >
<div class="col-sm-12" >
<?php
$p = array();
$p['horizontal'] = false;
$p['label_class'] = ' btn-block';
$form->addElement('submit', 'submit', 'Save Info', $p);
?>
</div >
</div >
</form >
</div >
<script language='JavaScript' >
$(function () {
$('#Name').focus();
})
</script >
<form action="" method="POST" role="form" >
<?php
$tf['choices'] = [1 => 'True', 0 => 'False'];
$who['choices']=['us'=>'Us','them'=>'Them']
$form = new bootstrapform($form_values, $options);
$form->submitted('process_form', 'hide');
$form->addElement('hidden', 'id');
$form->addElement('text', 'label', 'Label:');
$form->addElement('radio', 'display_item', 'Display:', $tf);
$form->addElement('select', 'assigned_to', 'Assigned:', $who);
$form->addElement('textarea', 'comments', 'Comments', array('rows' => 5));
$p = array();
$p['label_class'] = ' btn-block btn-success m-t';
$form->addElement('submit', 'submit', 'Button Label', $p);
?>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment