Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

UniqueRestrictedTextField broken?


Go to End


4 Posts   1387 Views

Avatar
dompie

Community Member, 88 Posts

3 September 2010 at 8:20pm

Edited: 03/09/2010 8:23pm

Hello,

I am using SS 2.4.1 and use an UniqueRestrictedTextField inside getCMSFields_forPopup. Although its values are saved, they are not validated and not checked for uniqueness.

		$code = new UniqueRestrictedTextField(
					'Roomcode',
					'Roomcode (must be unique)',
					'Room',
					'This roomcode is already in use.',
					'[A-Z0-9]{10}',
					'-',
					'Only letters and digits are allowed'
		);

I have followed the example from here. How can i make my DataObject validate this field?

Avatar
Willr

Forum Moderator, 5523 Posts

4 September 2010 at 8:17pm

UniqueRestrictedTextField and UniqueTextField are deprecated so you shouldn't rely on its functionality. Having a quick look at UniqueTextField shows that the restricted value lookup looks like its been commented out so you may need to uncomment that and see what that does.

Avatar
dompie

Community Member, 88 Posts

4 September 2010 at 8:40pm

Ah, I've put everything now into validate() but will try to go with AjaxUniqueTextField, which i discovered now :)
thanks

Avatar
dayer

Community Member, 11 Posts

11 September 2010 at 7:06am

Hi,

AjaxUniqueTextField what then is now the correct function for this?

Regards.