The Framework PHP Helpers



Examples of PHP Helper class: "HelperInputHidden"

DOWNLOAD version 0.1.0
released at 2018-02-25 19:50 GMT

  1. Download Helpers (zip file)
  2. Unzip it in your vendors folder (e.g)
  3. 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();
  4. Result: Example of HelperInputText



Resume

It helps to create html element "input type hidden":
<input type="hidden" value="some value to hide">

Examples:


Example 1


Live Html


PHP Code:

<?php
use TheFramework\Helpers\HelperInputHidden;
use TheFramework\Helpers\HelperButtonBasic;
use TheFramework\Helpers\HelperForm;

if(isset($_POST["hidOne"]))//required
    //pr(): is an echo function
    pr("{_POST[hidOne]:{$_POST["hidOne"]}, _POST[hidTwo]:{$_POST["hidTwo"]}}","\$_POST");

$oHidden1 = new HelperInputHidden();
$oHidden1->set_id("hidOne");
$oHidden1->set_name("hidOne");
$oHidden1->set_value((isset($_POST["hidOne"])?$_POST["hidOne"]:"some value for one"));

$oHidden2 = new HelperInputHidden();
$oHidden2->set_id("hidTwo");
$oHidden2->set_name("hidTwo");
$oHidden2->set_value((isset($_POST["hidTwo"])?$_POST["hidTwo"]:"some value for two"));

$oButton = new HelperButtonBasic();
$oButton->set_type("submit");
$oButton->add_class("btn btn-primary");
$oButton->add_extras("autofocus","autofocus");
$oButton->set_innerhtml("Press to Test");

$oForm = new HelperForm();
$oForm->set_id("myForm");
//$oForm->set_action("/");
$oForm->set_method("post");
$oForm->add_style("border:1px dashed #4f9fcf;");
$oForm->add_style("padding:5px;");
$oForm->add_inner_object($oHidden1);
$oForm->add_inner_object($oHidden2);
$oForm->add_inner_object($oButton);
$oForm->show(); 
?>

HTML Result:

<form id="myForm" method="post" style="border:1px dashed #4f9fcf;;padding:5px;">
<input type="hidden" id="hidOne" name="hidOne" value="some value for one">
<input type="hidden" id="hidTwo" name="hidTwo" value="some value for two">
<button type="submit" class="btn btn-primary" autofocus="autofocus">
Press to Test</button>
</form>