<?php /* lets suposse you have this folder tree yourproject/ vendors/ lib_1/ lib_n/ theframework/ -->uncompressed zip helpers/ index.php */ //this file is: yourproject/index.php include_once("vendors/theframework/helpers/autoload.php"); use TheFramework\Helpers\HelperInputText; $oInput = new HelperInputText(); $oInput->set_value("Hello World"); $oInput->add_class("form-control"); $oInput->show();
It helps to create html element "input type date|time":
<input type="date" value="2011-08-19">
<input type="time" value="13:45:00">
<?php use TheFramework\Helpers\HelperLabel; use TheFramework\Helpers\HelperDate; use TheFramework\Helpers\HelperDiv; use TheFramework\Helpers\HelperButtonBasic; use TheFramework\Helpers\HelperForm; if(isset($_POST["datDate"]))//required //pr(): is an echo function pr("{datDate:{$_POST["datDate"]},datTime:{$_POST["datTime"]}}","\$_POST"); //FIELD 1 DATE $oLabel = new HelperLabel(); $oLabel->set_for("datDate"); $oLabel->add_class("col-2 col-form-label"); $oLabel->set_innerhtml("Date:"); $oDate = new HelperDate(); $oDate->set_type("date"); //you can change to phone format. $oDate->set_separator("/"); $oDate->set_id("datDate"); $oDate->set_name("datDate"); $oDate->add_class("form-control col-2"); $oDate->set_value((isset($_POST["datDate"])?$_POST["datDate"]:NULL)); $oDivrow = new HelperDiv(); $oDivrow->add_class("form-group row"); $oTmp = new HelperDiv(); $oTmp->set_class("col-10"); $oTmp->add_inner_object($oDate); $oDivrow->add_inner_object($oLabel); $oDivrow->add_inner_object($oTmp); //FIELD 2 TIME $oLabel2 = clone $oLabel; $oLabel2->set_for("datTime"); $oLabel2->add_class("col-2 col-form-label"); $oLabel2->set_innerhtml("Time:"); $oTime = new HelperDate(); $oTime->set_type("time"); $oTime->set_separator(":"); $oTime->set_id("datTime"); $oTime->set_name("datTime"); $oTime->add_class("form-control col-2"); //$oTime->add_style("border: black 1px dashed"); $oTime->required(); $oTime->set_value((isset($_POST["datTime"])?$_POST["datTime"]:NULL)); if(isset($_POST["datTime"])) $oTime->add_extras("autofocus","autofocus"); $oDivrow2 = new HelperDiv(); $oDivrow2->add_class("form-group row"); $oTmp = new HelperDiv(); $oTmp->set_class("col-10"); $oTmp->add_inner_object($oTime); $oDivrow2->add_inner_object($oLabel2); $oDivrow2->add_inner_object($oTmp); $oButton = new HelperButtonBasic(); $oButton->set_type("submit"); $oButton->add_class("btn btn-primary"); $oButton->set_innerhtml("Submit"); $oForm = new HelperForm(); $oForm->set_id("myForm"); $oForm->set_method("post"); $oForm->add_style("border:1px dashed #4f9fcf;"); $oForm->add_style("padding:5px;"); //$oForm->add_class("form-inline"); $oForm->add_inner_object($oDivrow); $oForm->add_inner_object($oDivrow2); $oForm->add_inner_object($oButton); $oForm->show(); //show() is the same as echo $oForm->get_html(); ?>
<form id="myForm" method="post" style="border:1px dashed #4f9fcf;;padding:5px;"> <div class="form-group row"> <label for="datDate" class="col-2 col-form-label">Date:</label> <div class="col-10"> <input type="date" id="datDate" name="datDate" class="form-control col-2" as="date" data-options="{"useClearButton":true}"></div> </div> <div class="form-group row"> <label for="datTime" class="col-2 col-form-label col-2 col-form-label">Time:</label> <div class="col-10"> <input type="time" id="datTime" name="datTime" required="" class="form-control col-2" as="date"></div> </div> <button type="submit" class="btn btn-primary"> Submit</button> </form>