I am attaching a few fields from the user entity to a custom form with the following:
$account = user_load($user->uid);
foreach ($fields_to_collect as $field) {
field_attach_form('user', $account, $form, $form_state, NULL, [
'field_name' => $field
]);
}
This works fine except for date fields (I am using the date_popup widget but I haven't yet narrowed that down as responsible). Attaching a date field results in the following error: Warning: implode(): Invalid arguments passed in date_limit_format() (line 2262 of sites/all/modules/date/date_api/date_api.module).
The date field is just shown as a text field with the text Format
shown as a description.
The error is due to $granularity
being NULL
. On, for example, the user account edit page which has this field, $granularity
is something like:
[
'month',
'day',
'year'
]
Thanks for any help/suggestions.