fullscreeninteractive / silverstripe-ajaxuniquetextfield
Text field that checks uniqueness via AJAX and server-side validation for a DataObject field.
Package info
github.com/fullscreeninteractive/silverstripe-ajaxuniquetextfield
Type:silverstripe-vendormodule
pkg:composer/fullscreeninteractive/silverstripe-ajaxuniquetextfield
Requires
- php: ^8.3
- silverstripe/framework: ^6
- silverstripe/vendor-plugin: ^3
Requires (Dev)
- phpstan/phpstan: ^2
- phpunit/phpunit: ^11.3
- silverstripe/sqlite3: dev-master
- squizlabs/php_codesniffer: ^3.10
Suggests
- silverstripe/admin: Provides jQuery Entwine in the CMS; load jQuery and entwine before the field script on the front-end.
This package is auto-updated.
Last update: 2026-04-12 04:25:39 UTC
README
Provides AjaxUniqueTextField with client and server-side uniqueness validation on a DataObject field, an HTTP
JSON endpoint, and a jQuery Entwine client script (load jQuery and Entwine in your project; the CMS admin already
includes them).
Requirements
- SilverStripe CMS 6.x (
silverstripe/framework^6) - PHP 8.3 or newer
Installation
Install with Composer from your project root (the same directory as your site’s composer.json):
composer require fullscreeninteractive/silverstripe-ajaxuniquetextfield
Then rebuild the database manifest so configuration and routes are picked up:
vendor/bin/sake dev/build flush=1
Or open /dev/build?flush=1 in the browser while logged in as an administrator.
Exposed module assets are published by the vendor plugin. If JavaScript does not load after an upgrade, run:
composer vendor-expose
Usage
use FullscreenInteractive\AjaxUniqueTextField\AjaxUniqueTextField; $fields->push( AjaxUniqueTextField::create('Slug', 'URL segment', $this->Slug) ->setRecordClass(MyRecord::class) ->setUniqueField('Slug') ->setExcludeID($this->ID) // when editing an existing record // ->setValidateURL('https://example.com/custom-check') // optional // ->setRestrictedRegex('^[a-z0-9-]+$') // optional client-side gate before AJAX );
The constructor matches TextField: name, title, value, optional maxLength, optional Form. Configure the
DataObject class and field name with setRecordClass() and setUniqueField() before the field is rendered or
validated.
Development
composer test— PHPUnit (requires MySQL; seevendor/silverstripe/framework/tests/bootstrap/environment.phpfor defaults).composer phpcs— PSR-12 via PHP_CodeSniffer.composer phpstan— static analysis.