Download the PHP package flsouto/htfield without Composer

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

HtField

Overview

The HtField class is a base class for implementing all kinds of form fields, both widgets and non-widgets. It is basically a wrapper for two things:

For understanding these concepts more deeply I recommend you take a look at the two underlying libraries being used by this class:

Installation

Install this library via composer

Usage

As this is an abstract class, it is only useful if you want to build your own form field types. Therefore in this document I will show you how you can extend it in order to implement a very simple widget.

Defining a Simple Widget

Our example widget is going to be poor in functionality but will be enough for demonstrating the base API. We are going to call it 'MyField'. See its definition below:

Rendering the Field

To render a field instance simply print it out:

The output will be:

Changing the ID

By default, all fields have a default, random id. You can change it to a custom string by calling the attributes API. See example below:

The output will be:

Retrieving the ID

Use the $field->id() method for that:

Outputs:

The name attribute

The name is a special attribute that can only be set once via constructor. However you can access it's value later by using the $field->name() getter:

Outputs:

Processing Input

The $field->process() method returns an object which contains two properties:

But, before you can process anything you must specify the source of input. In other words, you must set the "context" from which the data is to be extracted. See example:

Outputs:

Observations

Processing Namespaced Fields

A field can have a fully qualified name in the following form:

This means that the input is expected to be found in a data structure like this:

Here is an example of this concept in action:

Output:

The $field->value() shortcut

Instead of writing the rather verbose statement $field->process()->output you can simply call $field->value() which has the same effect:

Results in:

The $field->validate() shortcut

This is an alias to $field->process()->error:


All versions of htfield with dependencies

PHP Build Version
Package Version
Requires flsouto/param Version ^1.0
flsouto/htattrs 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/htfield contains the following files

Loading the files please wait ....