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.

General Questions /

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

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

UniqueRestrictedTextField broken?


Reply


4 Posts   773 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 [url=http://doc.silverstripe.org/uniquerestrictedtextfield/]here[/url]. How can i make my DataObject validate this field?

Avatar
Willr

Forum Moderator, 5513 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.