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).
- SilverStripe CMS 6.x (
silverstripe/framework^6) - PHP 8.3 or newer
Install with Composer from your project root (the same directory as your site’s composer.json):
composer require fullscreeninteractive/silverstripe-ajaxuniquetextfieldThen rebuild the database manifest so configuration and routes are picked up:
vendor/bin/sake dev/build flush=1Or 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-exposeuse 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.
composer test— PHPUnit (requires MySQL; seevendor/silverstripe/framework/tests/bootstrap/environment.phpfor defaults).composer phpcs— PSR-12 via PHP_CodeSniffer.composer phpstan— static analysis.