Hi,
I'm trying to set up a site using SilverStripe and I want to add a field to pages that must be unique, it looks like I can do this using the AjaxUniqueTextField class but I can't find any documentation on how to use it.
The constructor takes several arguments but I don't know what several of them should be, could someone please point me towards some documentation or provide an example of a text field that must be a unique value.
$name - The database field this form field is for.
$title - What to display to the user.
$restrictedField - ?
$restrictedTable - ?
$value - ?
$maxLength - Max length the input can be.
$validationURL - ?
$restrictedRegex - A regex the input must match to be valid?
public static $db = array(
'page_id' => 'varchar(32)'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new AjaxUniqueTextField('page_id', 'Page Id', $restrictedField, $restrictedTable, $value, 32, null, $restrictedRegex), 'Content');
return $fields;
}
Cheers,
James Bench