I am building a simple admin module with a custom user registration form. The form displays fields from the user template. In the user template, I have set the 'email' field to required. This is an override, because the field itself is not required. So the field is only required in the context of the user template. However, when creating a new user form with the API, this override seems to be ignored and the email field is not required. Am I missing something? This is my code:
// Make a form.
$form = $modules->get('InputfieldForm');
$form->method = 'post';
$form->action = './';
// Add the user template's fields to the form.
$fields = $templates->get("user")->fieldgroup;
foreach($fields as $field) {
// Do not display certain system fields.
$skip = array('admin_theme', 'language', 'roles', 'pass');
if (in_array($field->name, $skip)) continue;
$inputfield = $fields->get($field->name)->getInputfield(new user());
$form->add($inputfield);
}