Live Html
PHP Code:
<?php
use TheFramework\Helpers\HelperForm;
use TheFramework\Helpers\HelperLabel;
use TheFramework\Helpers\HelperSelect;
$oForm = new HelperForm();
$oForm->add_class("form-inline");
//$_GET["warning"]=1 test: http://helpers.theframework.es/index.php?example=helperselect&warning=1
//bugg();
if($oPagedata->get_get("warning"))
$oForm->add_style("border:1px solid red;");
$oLabel = new HelperLabel("","Date:");
$oForm->add_control($oLabel);
$arOptions = [""=>"Month..."
,"1"=>"January","February","March","April","May"
,"June","July","August","September","October","November"
,"December"
];
//creating an instance of helper select
$oSelect = new HelperSelect($arOptions,"selMonth","selMonth");
$oSelect->set_class("custom-select mb-2 mr-sm-2 mb-sm-0");
$oSelect->set_value_to_select("7");// default selection
$oForm->add_control($oSelect);
$arOptions = [""=>"Year..."
,"2014"=>"2014","2015"=>"2015"
,"2016"=>"2016","2017"=>"2017"
,"2018"=>"2018","2019"=>"2019"
];
$oSelect = new HelperSelect($arOptions,"selYear","selYear");
$oSelect->set_class("custom-select mb-2 mr-sm-2 mb-sm-0");
$oSelect->set_value_to_select("2019");// default selection
$oForm->add_control($oSelect);
$oForm->show();
?>
HTML Result:
<form method="post" class="form-inline">
<label>Date:</label>
<select id="selMonth" name="selMonth" size="1" class="custom-select mb-2 mr-sm-2 mb-sm-0">
<option value="">Month...</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7" selected="">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="selYear" name="selYear" size="1" class="custom-select mb-2 mr-sm-2 mb-sm-0">
<option value="">Year...</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019" selected="">2019</option>
</select>
</form>
Live Html
PHP Code:
<?php
use TheFramework\Helpers\HelperForm;
use TheFramework\Helpers\HelperLabel;
use TheFramework\Helpers\HelperSelect;
use TheFramework\Helpers\HelperRaw;
//https://v4-alpha.getbootstrap.com/components/forms/#form-layouts (customized)
$oForm = new HelperForm();
$oForm->add_class("form-inline");
$oLabel = new HelperLabel("inlineFormCustomSelect","Preference");
$oForm->add_control($oLabel);
$arOptions = [""=>"Choose..."
,"1"=>"One","Two","Three"
];
//creating an instance of helper select
$oSelect = new HelperSelect($arOptions,"inlineFormCustomSelect","inlineFormCustomSelect");
$oSelect->set_class("custom-select mb-2 mr-sm-2 mb-sm-0");
$oForm->add_control($oSelect);
$oLabel = new HelperLabel();
$oLabel->add_class("custom-control custom-checkbox mb-2 mr-sm-2 mb-sm-0");
$oLabel->add_inner_object(new HelperRaw("<input type=\"checkbox\" class=\"custom-control-input\">"));
$oLabel->add_inner_object(new HelperRaw("<span class=\"custom-control-indicator\"></span>"));
$oLabel->add_inner_object(new HelperRaw("<span class=\"custom-control-description\">Remember my preference</span>"));
$oForm->add_control($oLabel);
$oForm->add_control(new HelperRaw("<button type=\"submit\" class=\"btn btn-primary\">Submit</button>"));
$oForm->show();
?>
HTML Result:
<form method="post" class="form-inline">
<label for="inlineFormCustomSelect">Preference</label>
<select id="inlineFormCustomSelect" name="inlineFormCustomSelect" size="1" class="custom-select mb-2 mr-sm-2 mb-sm-0">
<option value="" selected="">Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<label class="custom-control custom-checkbox mb-2 mr-sm-2 mb-sm-0"><input type="checkbox" class="custom-control-input"><span class="custom-control-indicator"></span><span class="custom-control-description">Remember my preference</span></label>
<button type="submit" class="btn btn-primary">Submit</button>
</form>