Download .zip |
Info | Example | View files (9) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2020-03-28 (19 hours ago) | Not enough user ratings | Total: 138 This week: 11 | All time: 8,928 This week: 27 |
Version | License | PHP version | Categories | |||
formone 1.0.1 | GNU Lesser Genera... | 5 | HTML, PHP 5 |
Description | Author | |
This class can generate HTML form composed programatically. |
|
Creates HTML web Form on PHP
Instead of write this code
<form method='POST' enctype='multipart/form-data' >
<label for='field1'>field 1:</label>
<input type='text' name='field1' id='field1'value='' />
<br>
</form>
Use instead this one
<?php
$f=new \eftec\FormOne();
echo $f->start();
echo $f->id('field1')
->label('field 1:')
->type('label')
->render();
echo $f->id('field1')
->type('text')
->render();
echo $f->renderRaw('<br>');
echo $f->end();
It's the end of the chain. It generates the end result (html)
Start a form (<form>)
End a form (</form>)
It sets the identifier of the current form.
It marks the prefix used by the name fields. Example "frm_"
Sets the name of the current chain.
> Note: if id() is not set at the end of the chain then, it also sets the id
it sets the id of the current chain.
> Note: if name() is not set at the end of the chain then, it also sets the name
It sets the attribute disable of the chain
| type | Description |
|----------|-------------------------|
| select | `
<select>`
|
| text | `
<input type='text'>`
|
| hidden | `
<input type='hidden'>`
|
| password | `
<input type='password'>`
|
| email | `
<input type='email'>`
|
| number | `
<input type='number'>`
|
| checkbox | `
<input type='checkbox'>`
|
| radio | `
<input type='radio'>`
|
| textarea | `
<textarea></textarea> `
|
| label | `
<label>label</label>`
|
| submit | `
<button type='submit'>submit</button>`
|
| button | `
<button type='button'>button</button>`
|
It adds a class to the current element. You could add many classes using different calls. Examples:
$form
->addClass("col-sm-2 col-form-label")
$form
->addClass("col-sm-2")
->addClass("col-form-label")
It adds a class to all elements of a type
$f->classType('label','col-sm-2 col-form-label'); // for all labels
$f->classType('text','col-sm-10 form-control'); // for all textbox
$f->classType('select','col-sm-10 form-control'); // for all select
It sets the current value, for example the default value of a textbox
It sets the value of the element. It's different to value because it's used when the value is "checked"
It sets the label of the element. It is used for label,checkbox,radiobuttons and buttons (inner html)
It adds a simple item to a list. It is commonly used by type="select"
$form->addItem('','--select a field--')
$form->addItem(['id'=>'','text'=>'--select a field--'])
it adds multiple items to a list.
$array=[
['id'=>1,'text'=>'America'],
['id'=>2,'text'=>'Asia'],
['id'=>3,'text'=>'Europa'],
];
$form->addItem($array)
$form->type('label')
->id('id')
->addClass("col-sm-2 col-form-label")
->inner('Id 1:')
->render()
it renders
<label for='id' class="col-sm-2 col-form-label">Id 1:</label>
Copyright Jorge Castro Castillo Eftec 2018
This program is supplied as dual license, LGPLV2 or commercial.
Files |
File | Role | Description | ||
---|---|---|---|---|
examples (5 files) | ||||
lib (1 file) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Read me |
Files | / | examples |
File | Role | Description |
---|---|---|
common.php | Example | Example script |
firstexample.php | Example | Example script |
firstexamplebootstrap.php | Example | Example script |
html.php | Example | Example script |
htmltable.php | Example | Example script |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.