You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've implemented the Select2AjaxField using a DataObject class as the source on a CMS form and it all works fine except for saving - the validation fails. Looking through the code it appears that the validate method is not overridden and ends up being handled by the SingleSelectField parent which checks the selection against what it knows as the list of valid values ( which in Select2AjaxField case is blank) and cannot find the selected value and so fails the validation.
I'd suggest the validate method should be overridden in Select2AjaxField and checks that the value is a valid member of the source DataList. Happy to contribute the changes of course (once I've done them)
The text was updated successfully, but these errors were encountered:
publicfunctionvalidate($validator)
{
$value = $this->Value();
$item = $this->getList()->find($this->getIDField(), $value);
if($item!==null)returntrue;
$validator->validationError(
$this->name,
_t(
'SilverStripe\\Forms\\DropdownField.SOURCE_VALIDATION',
"Please select a value within the list provided. {value} is not a valid option",
array('value' => $value)
),
"validation"
);
returnfalse;
}
I've implemented the Select2AjaxField using a DataObject class as the source on a CMS form and it all works fine except for saving - the validation fails. Looking through the code it appears that the validate method is not overridden and ends up being handled by the SingleSelectField parent which checks the selection against what it knows as the list of valid values ( which in Select2AjaxField case is blank) and cannot find the selected value and so fails the validation.
I'd suggest the validate method should be overridden in Select2AjaxField and checks that the value is a valid member of the source DataList. Happy to contribute the changes of course (once I've done them)
The text was updated successfully, but these errors were encountered: