Download the PHP package wavevision/dependent-selectbox without Composer

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

Wavevision s.r.o.

Dependent SelectBox

CI Coverage Status PHPStan Nette Forms Naja

Dependent select box component for nette/forms with naja extension on client side.

Features:

Installation

Use Composer to get the Nette forms component

Install the client side via Yarn

or npm

Usage

Server side

Create a form that will be an instance of Wavevision\DependentSelectBox\Form\Form.

If you don't want to / cannot inherit from our base form, just make sure the form you create uses Wavevision\DependentSelectBox\Form\DependentForm trait.

Your form should also use Wavevision\DependentSelectBox\Form\DependentContainer to have its containers extended with the dependent select box too, however, if you already have your own implementation of Nette\Forms\Container, just make sure the container uses Wavevision\DependentSelectBox\Form\DependentControl trait.

After this, your form and its containers will be extended with addDependentSelectBox method. This method accepts following arguments:

Argument Type Description
$name string name of the control
$label string label for the control
...$parents Nette\Forms\Controls\BaseControl[] list of form controls whom's values will be treated as parent values to get the dependent data

The method returns an instance of Wavevision\DependentSelectBox\DependentSelectBox.

The recommended way of using the form is in a Control component.

NOTE: You can use the form in a Presenter too, the only limitation is that you can only have one dependent form per page like this. If you wrap your form in a component (each using DependentComponent trait), you can then use as many forms on one page as you wish.

Client side

There are a few ways of integrating the client side into your project.

1. Register dependent select box as Naja extension

As mentioned in features, the extension emits events you can attach listeners to.

Event Description
dependentSelectBoxLoading fires right after a parent changes and a request to server is being dispatched
dependentSelectBoxLoaded fires when the data loading is finished

Listeners for both events will receive a CustomEvent object containing detail with these properties:

Property Type Description
form HTMLFormElement the form in which the event has been triggered
dependentSelectBoxes HTMLSelectElement[] an array of all dependent select boxes in the form

The first event also contains request property, which is an object containing:

Property Type Description
trigger string HTML id of a parent that triggered the request
values ParentsValues object with current values of parents and filled select boxes (HTML name properties of elements are used as keys)

The latter one contains response object, in which keys are HTML id attributes of updated select boxes and values are objects with:

Property Type Description
disabled boolean select box state
items string inner HTML of the select box

Please, refer to Naja docs to find out more about its extensions.

2. Import bundled version with Naja included

If you don't use Naja elsewhere in your project an you don't want to set it up, this is your way to go.

⚠️ WARNING: This might collide with other Nette AJAX libraries, if used!

3. Use it directly in a script tag

For old-school people only 😎.


All versions of dependent-selectbox with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
nette/forms Version ^3.0
wavevision/utils Version ^2.1
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 wavevision/dependent-selectbox contains the following files

Loading the files please wait ....