How to make a mixed field type required 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' =&gt; array(AttributeType::Mixed, 'required' =&gt; true),
'myEndDate' =&gt; array(AttributeType::Mixed, 'required' =&gt; 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' =&gt; array(AttributeType::Mixed, 'required' =&gt; true),
                 'myEndDate' =&gt; array(AttributeType::Mixed, 'required' =&gt; 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.
100% untested and I haven't had coffee yet, but I think it'd be a combination of a few things.

1) Having your plugin override BaseSavableComponentType's getSettingsModel() so that it returned a MyPluginSettingsModel().

2) Have MyPluginSettingsModel override the rules method to do something like:

public function rules()
{
    $rules = parent::rules();

    $rules[] = array('myStartDate, myEndDate', 'required');

    return $rules;
}