fullscreeninteractive/silverstripe-ajaxuniquetextfield
Composer 安装命令:
composer require fullscreeninteractive/silverstripe-ajaxuniquetextfield
包简介
Text field that checks uniqueness via AJAX and server-side validation for a DataObject field.
README 文档
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.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2026-04-12