Download the PHP package asgard/entityform without Composer

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

EntityForm

Build Status

Entityform help you generate forms from entities. It creates the form fields corresponding to all the entity properties. Entityform is a sub-class of Form.

Installation

If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries.

composer require asgard/entityform 0.*

Usage in the Asgard Framework

The advantage of using the form service is that it will provides the Form with all the necessary dependencies:

$request = \Asgard\Http\Request::CreateFromGlobals();
$entity  = new Article;
$container->make('entityForm', [
    $entity, #required
    [ #optional
        'action'  => 'form.php',
        'enctype' => 'multipart/form-data',
        'attrs'   => [
            'class' => 'formClass'
        ]
    ],
    $request, #optional, Asgard can provide the form with the current request
]);

The singleton but it is not recommended.

Usage outside the Asgard Framework

Here you will have to provide the dependencies yourself (see the next section):

$entityFieldsSolver = new \Asgard\Entityform\EntityFieldsSolver;
$request            = \Asgard\Http\Request::CreateFromGlobals();
$entity             = new Article;
$form = new \Asgard\Entityform\Entityform(
    $entity, #required
    [ #optional
        'action'  => 'form.php',
        'enctype' => 'multipart/form-data',
        'attrs'   => [
            'class' => 'formClass'
        ]
    ],
    $request, #optional, if not request is provided the form will automatically use \Asgard\Http\Request::createFromGlobals()
    $entityFieldsSolver #optional, Asgard can automatically retrieve an instance of EntityFieldsSolver
);

Add entity relations

If the entity form was created from an entity having a "comments" relation, you embed it in the form with:

$form->addRelation('comments');

This will add a field for selecting comments related to the entity. Works for all kinds of relations, "one" and "many".

Save the entity

To save the entity, simple do:

$form->save();

If there is a validation error, it will throw the exception \Asgard\Form\FormException. Refer to the Form documentation to know how to handle exceptions and errors.

Get the entity

$form->getEntity();

EntityFieldSolver

In order to tell the entityform how to create fields from entity properties, you can use the Asgard\Entityform\EntityFieldsSolver class. By default it already handles Text, text, Double, Integer, Email, Boolean, Date, Datetime, File entity properties (all in Asgard\Entity\Property\). If the EntityFieldsSolver does not know what type of field to create for a specific property, it will return a \Asgard\Form\Field\TextField field by default.

To extend the entityFieldsSolver add a callback which will return a form field object:

$cb = function(\Asgard\Entity\Property $property) {
    if(get_class($property) == 'Asgard\Entity\Property\DateProperty')
        return new MyOwnDateField;
};
$fieldsSolver->add($cb);

For entity properties with multiple values, use:

$cb = function(\Asgard\Entity\Property $property) {
    if(get_class($property) == 'Asgard\Entity\Property\DateProperty')
        return new \Asgard\Form\DynamicGroup;
};
$fieldsSolver->addMany($cb);

If the callback returns null it will be ignored.

You can also nest other solvers:

$anotherFieldsSolver->addSolver($fieldsSolver);

If $anotherFieldsSolver cannot solve the field, it will ask to the nested solvers.

To solve a field from an entity property:

$form->solve($Definition->getProperty('title'));

To get the EntityFieldSolver from a form:

$fieldsSolver = $form->getEntityFieldsSolver();

To set the EntityFieldsSolver for a form:

$form->addEntityFieldsSolver($cb);

Contributing

Please submit all issues and pull requests to the asgardphp/asgard repository.

License

The Asgard framework is open-sourced software licensed under the MIT license


All versions of entityform with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
asgard/form Version ~0.3.0
asgard/entity Version ~0.3.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 asgard/entityform contains the following files

Loading the files please wait ....