From this incredibly helpful validation article(s), I found that:
AttributeType::Mixed does not apply any validation rules
Ok cool. I am using two fields that are DateTime fields, but due to a known bug, a work-around is to make the field type Mixed
.
Everything is working 100% - and I can't thank the community for their help.
However, in my settings page, I would (like) to have my start date (Mixed) and end date (Mixed) fields required.
This isn't a make-or-break deal, just curious if there is a way.
MyPlugin.php
....
'myStartDate' => array(AttributeType::Mixed, 'required' => true),
'myEndDate' => array(AttributeType::Mixed, 'required' => true),
....
EDIT
Hi Brad, they are attribute settings. I've updated to show the file(s) below. Thank you for your time!
_settings.html
....
{{
forms.dateField({
'label': "Start Date"|t,
'instructions': "What week do we start?"|t,
'required': true,
'id': 'myStartDate',
'name': 'myStartDate',
'placeholder': 'mm/dd/yyyy',
'value': settings.myStartDate,
'errors': settings.getErrors('myStartDate')
})
}}
....
MyPlugin.php
public function defineSettings()
{
return array('myStartDate' => array(AttributeType::Mixed, 'required' => true),
'myEndDate' => array(AttributeType::Mixed, 'required' => true)
);
}
If I make the field type a DateTime, then the required works. Maybe it's all part of the same bug. If it is, that's cool. It's not a big deal I'm more curious if I'm doing something wrong for the field type since ::Mixed
does not apply any validation rules.