Never mind, it works fine after i have updated to 3.1.5 =))
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Previous 10 entries
- 1
- Page 22(current)
Hi All!
I just wanted to reuse this post since I have quite similar problem ant it could not be solved with the proposed approaches :-/
I am using SS V 3.1.13.
I have a simple DataObject that has a Varchar field "name". This attribute should be used only once (is unique) across the system.
I have used AjaxUniqueTextField but this construct is not working properly :-/ If saving an existing alraedy persisted DO it says the "name" is not unique (but it does!). In the AjaxUniqueTextField there is one important Thing missing - exclusion of all entries with ID of the current Instance if already persisted.
I tried to implement the proper validation in an inherited Class of RequiredFieldsValidator, but unfortunately I need the ID of the Record being validated, to build correct DB Query - but I can't find it in the $_REQUEST var anymore like in the previous answers.
Is there any other Pattern to implement Unique Value Validation?
Or how can I access the DO ID in the Validator?
Thanks in advance!
BR
code_dave
just insert
public function getValidator() {
// Answers a validator for the record.
return new RequiredFields('SystemName','Name');
}
in your dataobject
- Previous 10 entries
- 1
- Page 22(current)