Download the PHP package one234ru/form-inputs-generator without Composer

On this page you can find all versions of the php package one234ru/form-inputs-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 form-inputs-generator

ПО-РУССКИ

Generation of HTML form fields with supplementary tags

This class is a wrapper for HTMLinputGenerator. It solves two important problems:

  1. Looks for field's value using it's name in an array. This array may store, for example, data of some entity being edited or parameters of an HTTP query.

  2. Generation of supplementary HTML tags. HTMLinputGenerator always generates single HTML element, while in some cases it is handily to have a field as more complicated structure. These cases are:
    • <input type="checkbox/radio"> wrapped in <label>
    • a group of <input type="checkbox/radio"> with the same name
    • explicit value when <input type="checkbox"> is unchecked

Installation

Usage

To obtain an HTML code, you need to create an object based on configuration and data array and then convert it to string.

Configuration is extension of the one for HTMLinputGenerator and commonly yields identical HTML:

Special modes are only activated if certain keys are present in the configuration. All such cases are listed below.

Wrapping <input type = "checkbox/radio"> in <label>

CSS capabilities for checkboxes and radiobuttons are very poor and often insufficient to get desired appearance.
The workaround is to wrap a field with <label> tag, hide the field itself and add it's description right after, wrapped in <span> or <div> with background image. That image serves as a visual equvalent of the field (CSS allows to adjust styles depending on whether the field is checked or not; see an example in pseudocheckbox.html).

Moreso, wrapping text in a <label> makes it clickable for checking/unchecking the field, which improves user experience.

All of the above leads to a structure like:

This structure is easy to obtain — just add label element to the configuration:

Fine tuning is done through passing an array as label:

Result (formatted for readability):

Two following configurations yield the same result:

Same techique is applicable to <input type="radio">.

For type, different than 'checkbox' or 'radio', specifying label does not affect anything.

A group of <input type="checkbox/radio"> with the same name

Group generation mode is turned on by value parameter:

Result (formatted for readability):

All fields, except last, are wrapped in <label>. Keys of every element in label array has same effect as in the case of single field described above.

First field's configuration is a key-value pair — 1 => 'One'. This is equivalent of the array:

The fourth field doesn't have any wrapper. This may be achieved by specifying configuration as an array without label attribute.

Standard keys (like attr and label) may be specified at the top level — they will be inherited by all values members and may be redefined for every one in particular:

In the case of type="checkbox" empty square brackets are appended to name attribute's value:

For any type, other than 'checkbox' or 'radio', values parameter is ignored.

Explicit value when <input type="checkbox"> is unchecked

Checkboxes affect HTTP query only when checked. Otherwise corresponding key is just absent, and on the receiving end suggestions like "if there is no explicit 'Yes' — treat this as 'No'" have to be made.

It may be more convenient to have 'No' in explicit form. This is achieved with the trick: the checkbox is prepended by a hidden field with the same name and a value corresponding to the 'No' variant:

If the checkbox is checked, it's value will override hidden field's value in the query.

Generation of such hidden field is turned on by off_value parameter, which holds the actual value. HTML code in the example above corresponds to the following configuration:

off_value works fine with label and other stanard parameters:

If type is not equal to 'checkbox', off_value has no effect.


All versions of form-inputs-generator with dependencies

PHP Build Version
Package Version
Requires one234ru/html-input-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/form-inputs-generator contains the following files

Loading the files please wait ....