Download the PHP package flsouto/htform without Composer

On this page you can find all versions of the php package flsouto/htform. 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 htform

HtForm

Installation

To install this package use composer:

Overview

Forget about everything you've seen so far regarding form building tools and libraries. The approach you are going to see here is something totally new and straightforward:

Usage

All you have to do is this: create a form object, add some fields and echo it:

Outputs:

That is pretty easy, huh?

Adding labels to fields

By default fields don't have a label but you can add one by calling the label setter on a field instance:

Outputs:

Making field labels inline

By default a field's label is a block level element. You can change that by passing the inline => true flag:

Outputs:

Defining Placeholders

You can use the placeholder setter which is really just a shortcut for setting the field's 'placeholder' attribute:

Outputs:

Other attributes can be set by passing an associative array to the field's attrs method.

Adding different types of fields

A form is all about attaching a bunch of fields for taking user input. Different field types are available in this library:

Outputs:

Each field type is defined in its own class. These classes have a repostory of their own too. For more info on the fields API, take a look in the following repositories:

Notice: when adding the "upload" field the form will automatically have enctype=multipart/form-data and method=POST

Make all fields inline at once

Sometimes you need to build "quick search" type of forms in which all fields are rendered in a single line. For this you can use the inline method on the form instance:

Outputs:

Make all fields readonly at once

Sometimes you want to reuse the same form layout/structure but in readonly mode. In this case you can call the readonly method of the form object in order to disable editing on all fields:

Outputs:

Changing Form Attributes

By default, the form is rendered with the following attributes:

But these can be changed easily by calling the corresponding setters on the form instance:

Outputs:

Populate form with data

In order to populate the form with data you have to call the context method on the form object and pass an associative array to it. The keys of the associative array must match the names of the fields you added to the form:

Outputs:

Processing form submission

Processing a form is all about populating it with incoming data and calling the process method. It is also good practice to check if a flag is present indicating that the form has been sent. Check this out:

Outputs:

Validate form submission

You can add validation rules to be checked upon form submission. Validation rules are added on a per-field basis and yield error messages when something is wrong. These errors are available in the result object returned by the process method. Take a look:

Outputs:

Namespacing form fields

The data structure behind your form doesn't have to be flat. You can group fields into logical sections, see example below:

Outputs:

Unfold form data

As you may have seen in the last example, even though we can process complex data structures sent over a request, the data is extracted in a flat format. Luckily, the result object provides a method called unfold which can be used to reconstruct the data into a multidimensional array:

Outputs:


All versions of htform with dependencies

PHP Build Version
Package Version
Requires flsouto/htattrs Version ^1.0
flsouto/htbutton Version ^1.0
flsouto/hthidden Version ^1.0
flsouto/httextin Version ^1.0
flsouto/httextar Version ^1.0
flsouto/htcheckb Version ^1.0
flsouto/htselect Version ^1.0
flsouto/htupload Version ^1.0
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 flsouto/htform contains the following files

Loading the files please wait ....