Download the PHP package one234ru/html-input-generator without Composer

On this page you can find all versions of the php package one234ru/html-input-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package html-input-generator

ПО-РУССКИ

HTML form input generation based on configuration array

This tool generates HTML source code of miscellaneous web form fields - <input>, <select> and <textarea> - based on simple configurations.

The library is based on one234ru/html-tag-generator.

Installation

Usage

To obtain form field's HTML, you need to create field's object, passing two arguments to it's constructor: the field's configuration and a value, corresponding to the field. Converting object to string gives the HTML.

In the example below <input type="text" name="something"> is generated, it's value is extracted from the $_GET array:

Almost any configuration includes parameters type, name и attr:

type may hold following values.

'text' or empty string

An <input type="text"> is generated. The value attribute is set to the second constructor's argument, processed with htmlspecialchars():

Result (formatted for readability):

'text' is a default value for type and will be applied if it is empty or absent.

'textarea'

A <textarea> will be generated, with the value is used as contents:

Result (formatted for readability):

'checkbox' and 'radio'

This variant yields an <input> of the corresponding type.

The value parameter may be specified. If it matches the value passed to the constructor, field's checked attribute is turned on:

Non-strict comparison is performed when matching. false is returned in the particular case of matching integer 0 and an empty string.

'submit', 'reset'

An <input> of the corresponding type is generated.

The value parameter, if specified, goes to the namesake attribute.

Constructor's second agrument has no effect.

'hidden'

<input type="hidden"> may be generated with value attribute coming from HTTP query:

If value is explicit, second agrument will be ignored:

'file'

Yields <input type="file">. Other working parameters are name and attr.

'select'

A <select> tag is generated.

options, optgroups and multiple join standard configuration parameters.

options parameter

Holds list of options, any of which may be declared in two ways:

  1. As an array with keys value, text and, optionally, attr.
    value becomes namesake's attribute value, text<option> tag's contents.

  2. As a key-value pair.
    In this case a key is treated as value, and a value — as text.

If an option's value matches the value passed to constructor, it's selected attribute is set:

HTML (formatted for readability):

multiple flag

Turning this parameter on sets the namesake attribute and also affects two major aspects:

  1. The name attribute is appended with a pair of empty brackets — [].
    So don't put [] there yourself.

  2. The way of matching options' values to the value, passed to constructor, is changed: search in array is done instead of simple comparison.

optgroups parameter

This parameter groups options into <optgroup> tags. This tags may also have attributes, particularly label — visible group title.

Groups and standalone options may coexist.

Any other type value

If a value doesn't fall under any of the cases above, an <input> tag is generated, type goes straight to tag's namesake attribute, while the value passed to constructor — to tag's value attribute.

Result is very similar to type='text' case.


All versions of html-input-generator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
one234ru/html-tag-generator Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package one234ru/html-input-generator contains the following files

Loading the files please wait ....