<?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 file":
<input type="file" id="fileUpload" name="fileUpload">
use TheFramework\Helpers\HelperLabel; use TheFramework\Helpers\HelperInputFile; use TheFramework\Helpers\HelperForm; use TheFramework\Helpers\HelperDiv; use TheFramework\Helpers\HelperRaw; use TheFramework\Helpers\HelperButtonBasic; //<label for="exampleInputFile">File input</label> $oLabel = new HelperLabel(); $oLabel->set_for("exampleInputFile"); $oLabel->set_innerhtml("Attach your file here:"); //<input type="file" class="form-control-file" id="exampleInputFile" aria-describedby="fileHelp"> $oFile = new HelperInputFile("exampleInputFile"); $oFile->set_name("fileUpload"); $oFile->add_class("form-control-file"); $oFile->add_extras("aria-describedby","fileHelp"); $oFile->add_extras("autofocus","autofocus"); //there is no such a "HelperSmall" that is why I use HelperRaw in place. $oRaw = new HelperRaw("<small id=\"fileHelp\" class=\"form-text text-muted\">" . "This is some placeholder block-level help text for the above input. " . "It's a bit lighter and easily wraps to a new line." . "</small>"); //<button type="submit" class="btn btn-primary">Submit</button> $oButton = new HelperButtonBasic(); $oButton->set_type("submit"); $oButton->add_class("btn btn-primary"); $oButton->set_innerhtml("Submit"); //<div class="form-group"> $oDiv = new HelperDiv(); $oDiv->set_comments("div for label and input"); $oDiv->add_class("form-group"); $oDiv->add_inner_object($oLabel); $oDiv->add_inner_object($oFile); $oDiv->add_inner_object($oRaw); $oForm = new HelperForm(); $oForm->set_action("/helper-input-file/examples/"); $oForm->set_id("myForm"); $oForm->set_comments("This is a comment"); $oForm->set_method("post"); $oForm->set_enctype("multipart/form-data"); $oForm->add_style("border:1px dashed #4f9fcf;"); $oForm->add_style("padding:5px;"); $oForm->add_inner_object($oDiv); $oForm->add_inner_object($oButton); $oForm->show();
<!-- This is a comment --> <form id="myForm" method="post" action="/helper-input-file/examples/" enctype="multipart/form-data" style="border:1px dashed #4f9fcf;;padding:5px;"> <div class="form-group"> <label for="exampleInputFile">Attach your file here:</label> <input type="file" id="exampleInputFile" name="fileUpload" class="form-control-file" aria-describedby="fileHelp" autofocus="autofocus"> <small id="fileHelp" class="form-text text-muted">This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line.</small></div> <button type="submit" class="btn btn-primary"> Submit</button> </form>