- Download Helpers (zip file)
- Unzip it in your vendors folder (e.g)
-
Include autoload.php in your bootstrap file
<?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();
-
Result:
Examples:
Example 1
Live Html
PHP Code:
<?php
use TheFramework\Helpers\HelperForm;
use TheFramework\Helpers\HelperLabel;
use TheFramework\Helpers\HelperInputText;
use TheFramework\Helpers\HelperSelect;
$arFields = [];
$oAux = new HelperLabel("txtNameId","My label for Name");
$oAux->add_class("custom-control");
$arFields[] = $oAux;
$oAux = new HelperInputText();
$oAux->add_class("col-4");
$oAux->add_class("form-control");
$oAux->add_extras("placeholder","Eg. Eduardo A. F.");
$oAux->set_id("txtNameId");
$oAux->set_name("txtName");
$arFields[] = $oAux;
$arFields["sel"] = new HelperSelect([""=>"choose...","one"=>"One","two"=>"Two","three"=>"Three"]);
$arFields["sel"]->add_class("form-control col-4");
$arFields["textarea"] = new TheFramework\Helpers\HelperTextarea();
$arFields["textarea"]->add_class("form-control");
$arFields["textarea"]->add_extras("placeholder","Your comments");
$arFields["textarea"]->set_id("txaComments");
$oForm = new HelperForm();
$oForm->add_class("col-6");
$oForm->add_style("border:1px dashed #4f9fcf;");
$oForm->add_style("padding:5px;");
$oForm->set_id("myForm");
$oForm->set_method("some_method");
$oForm->set_enctype("myEncType");
$oForm->add_controls($arFields);
$oForm->show();
?>
HTML Result:
<form id="myForm" method="some_method" enctype="myEncType" class="col-6" style="border:1px dashed #4f9fcf;;padding:5px;">
<label for="txtNameId" class="custom-control">My label for Name</label>
<input type="text" id="txtNameId" name="txtName" maxlength="50" class="col-4 form-control" placeholder="Eg. Eduardo A. F.">
<select name="" size="1" class="form-control col-4">
<option value="" selected="">choose...</option>
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
<textarea id="txaComments" rows="8" cols="40" class="form-control" maxlength="-1" placeholder="Your comments"></textarea>
<span id="sptxaComments"></span>
</form>
Example 2
Live Html
PHP Code:
<?php
$iBorder = 1;
$sAutofocus = "";
$oForm = new TheFramework\Helpers\HelperForm();
$oForm->set_id("frmIdSomeForm");
$oForm->add_style("border:1px dashed #4f9fcf;");
$oForm->add_style("padding:5px");
$oForm->set_class("col-7");
$oForm->set_enctype("multipart/form-data");
$oForm->set_method("post");
$oForm->set_action("index.php?example=helperform");
if(isset($_POST["border"]))
{
$sAutofocus = "autofocus=\"\" ";
$iBorder = (int)$_POST["border"];
//rewrite stack of styles
$oForm->set_style("border:{$iBorder}px solid #4f9fcf;");
$oForm->add_style("padding:15px");
$oForm->set_class("col-6");
}
$oButton = new \TheFramework\Helpers\HelperButtonBasic();
$oButton->set_innerhtml("Test tborder");
$oButton->set_type("submit");
$oForm->show_opentag();
echo "<label>Border</lable><input type=\"number\" name=\"border\" value=\"$iBorder\"$sAutofocus><br/>";
echo "<input type=\"email\" placeholder=\"your email\"><br/>";
echo "<input type=\"time\"><br/>";
$oButton->add_class("btn btn-danger");
$oButton->show();
$oForm->show_closetag();
?>
HTML Result:
<form id="frmIdSomeForm" method="post" action="index.php?example=helperform" enctype="multipart/form-data" class="col-7" style="border:1px dashed #4f9fcf;;padding:5px">
<label>Border</lable><input type="number" name="border" value="1"><br/><input type="email" placeholder="your email"><br/><input type="time"><br/><button type="submit" class="btn btn-danger">
Test tborder</button></form>
Back to Top