I've got a plugin with some custom settings, like this:
protected function defineSettings()
{
return array(
'serviceendpoint' => array(AttributeType::String, 'required'=>true),
'passkey' => array(AttributeType::String, 'required'=>true),
'newregistrationdate' => array(AttributeType::DateTime, 'required'=>false),
);
}
Then I have a _settings template, which renders the form:
{{ forms.textField({
first: true,
label: "CRM Endpoint URL"|t,
id: 'serviceendpoint',
name: 'serviceendpoint',
instructions: "The URL for the CRM service ."|t,
value: settings.serviceendpoint,
autofocus: true,
placeholder: "https://example.com/api/...",
errors: settings.getErrors('serviceendpoint')
}) }}
{{ forms.textField({
label: "The service passkey"|t,
id: 'passkey',
name: 'passkey',
instructions: ""|t,
value: settings.passkey,
placeholder: "1234...",
errors: settings.getErrors('passkey')
}) }}
<pre>Val: "{{ dump(settings.newregistrationdate) }}"</pre>
{{ forms.dateField({
label: "New registrations after this date"|t,
id: 'newregistrationdate',
name: 'newregistrationdate',
instructions: "Users registered after this date will get a welcome email"|t,
value: settings.newregistrationdate.date|default,
errors: settings.getErrors('newregistrationdate')
}) }}
The String-typed values are saved just fine. But the DateTime
always comes back as false
.
I've tried adding a prepSettings function, and doing:
$settings['newregistrationdate'] = new DateTime($settings['newregistrationdate']['date']);
but it makes no difference.
What does prepSettings
have to return for DateTime
typed fields?