Download the PHP package iamntz/carbon-chained-select without Composer
On this page you can find all versions of the php package iamntz/carbon-chained-select. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iamntz/carbon-chained-select
More information about iamntz/carbon-chained-select
Files in iamntz/carbon-chained-select
Package carbon-chained-select
Short Description Provides a chained select for Carbon Fields.
License MIT
Homepage https://github.com/iamntz/carbon-chained-select
Informations about the package carbon-chained-select
Carbon Field: chainedselect
Provides a chained select control.
Adds a chainedselect
field type to Carbon Fields. Install using Composer:
For Carbon Fields 2 (legacy):
add_option
array structure
Basically this is a multidimensional array with few magic keywords. These keywords are: __label__
, __config__
.
Any of these keys can be changed by using carbon_chained_select_config
filter, or, even furter, via carbon_chained_select_config/name=field-name
filter.
Alternatively, you can move all config-related within __config__
array:
Internally, this will be arranged as needed, so you don't need to worry too much about it.
For ajax calls, the response must follow the same structure, but must be parsed before is sent:
Second argument, fieldName
, is optional and used only for the config filter (i.e. for changing magic keywords).
Limitation
At this moment, you can't have chained & ajax within fields fetched via ajax.
So you chain fields like this:
But you cant chain fields like this:
Also, you can't have multiple select AND ajax on the same field.
Return values
Value returned is an associative array that follows the field names.
Known issues:
- [ ] You can't have another nested field after an ajax select. This might work but I didn't tested.
- [ ] You can't have another nested field after a select with multiple options. This one has a very very VERY low priority (mostly because the way I see it, is a UX nightmare) on my list.
- [ ] Conditional logic is broken on this field. This is caused by the way I store data in the DB (as a json string). Although I would like to make this work, I have to find some time to dig into Carbon Field conditional and understand its logic.
- [ ] Didn't tested, but setting a field as required should have the very same issue as the conditional logic above.
If you have any fixes, please send a PR!
Special Note on validation
Carbon's Select fields (both normal and multiselect) uses a validation that will make sure an user won't be able to select an option that doesn't exists in the provided array in config. However, considering that the source can be also external (i.e. via AJAX), this can't be implemented in a reasonable extensible way.
Most likely this won't affect anything, but if sometime in the future Carbon can be used on the frontend, this may be a gateway of abuses.
Support me
You can get hosting, donate or be my patreon.
License
The code is released under MIT license.
All versions of carbon-chained-select with dependencies
ext-json Version *