Download the PHP package adt/ajax-select without Composer

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

ADT AjaxSelect

Installation

  1. Install via composer:

  2. Register this extension in your config.neon:

  3. Include AjaxServiceSignalTrait in your BasePresenter:

  4. Include assets/ajax-select.js to your front-end build.

  5. Create your first AjaxEntity.
  6. Use this entity in your first AjaxSelect control.
  7. Done.

What does it do?

This extension adds following methods to Nette\Forms\Container and thus to all derived classes:

Config

AjaxSelectExtension::CONFIG_TRANSLATOR: Sets the automatic translation of select values on/off. Default is TRUE.

Dynamic Select

This control allows passing unknown value to $control->value field. Doing so will invoke control's $itemFactory with only one parameter - the invalid value.

The item factory can either return title for given value or empty value (NULL, empty string, zero etc.). Non-empty value is automatically appended to known list of valid values.

DynamicSelect accepts array or \Kdyby\Doctrine\QueryObject that extends \ADT\BaseQuery\BaseQuery in $items.

Following features are implemented if QO is passed:

Ajax Select

This control needs something we call AjaxEntity, and its factory. All user AjaxEntities need to derive from our AbstractEntity or AggregateEntity.

This AjaxEntity encapsulates $itemFactory's behaviour but it can get much more powerful.

AjaxSelect also uses orByIdFilter, see Dynamic Select.

Configuration

Implement AjaxEntity

First, create new class (ie. UserAjaxEntity) that derives from our \ADT\Components\AjaxSelect\Entities\AbstractEntity.

\ADT\Components\AjaxSelect\Entities\AbstractEntity requires few functions to be implemented. See example below.

In addition, we will need its factory, so create an interface (ie. IUserAjaxEntityFactory) too.

Example:

Then register this entity and its factory in your config.neon in services section:

This instructs Nette to autoimplement a factory for your entity and tag it as ajax-select.entity-factory. AjaxSelect knows about your entity now.

Now you can use your AjaxEntity direcly from your AjaxSelect control on your Nette form:

Arguments $entityName and/or $entitySetupCallback can be omitted. You can omit $entityName if it's equal to control name (ie. first argument $name).

Finally you have to call finalizing ajaxSelect after the form is attached to presenter. For example you can do it in your BaseForm::attached($presenter)

AjaxEntity name, its options and query URL are serialized to control's data-ajax-select HTML attribute.

Implement DynamicSelect with QueryObject

First, create new class (ie. User) that derives from \ADT\BaseQuery\BaseQuery.

In addition, We will need its factory, so create an interface (ie. IUserFactory) too.

Example:

Now you can create DynamicSelect on your Nette form:

Change signal name

If you ever need to change signal that is used in query URL, proceed as follows:

  1. edit your config.neon

  2. rename trait method

    Rewrite use AjaxServiceSignalTrait; as follows

Troubleshooting

Dynamic form containers (like addDynamic and toMany)

If you create a new form container which contains an input with AjaxEntity and you create it after calling $ajaxEntityPoolService->invokeDone(); (which is called typically after form initialization), then the ajax search will not work properly.

Example of such mistake:

Right solution:

ToDo

orById filtr pro zanořené selecty

Pokud máme select uvnitř toMany nebo addDynamic, tak musí být nastaveno AjaxSelectExtension::CONFIG_OR_BY_ID_FILTER => FALSE, aby se knihovna nepokoušela přistoupit k atributu dle názvu selectu v hlavní entitě, což by skončilo chybou. Toto rozšíření orById filtru pro zanořené selecty by se dalo naimplementovat, že bychom si v kontejneru selectu zjistili, kam je select zanořený (může být víc než jedna úroveň zanoření) a podle toho bychom místo $form->getEntity()->get{$atributeName}() provolali všechny prvky zanoření, tedy $form->getEntity()->get{$zanořenýPrvek}($indexPrvku)->...->get{$atributeName}()


All versions of ajax-select with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
nette/forms Version ^3.0
nette/di Version ^3.0
nette/utils Version ^3.0 | ^4.0
nette/application Version *
adt/base-query Version ^1.7
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 adt/ajax-select contains the following files

Loading the files please wait ....