I have a form with managed file field. Form has single field. I have declared this field as required and indeed after submit without file I have an error: Field is required.
I wanted to add HTML5 validation to this field, but in my custom theme_file implementation $variables array has #required => FALSE
for this field...
I have even red asterisk above this input field so I truly don't know what is wrong..
My custom theme_file:
function custom_file($variables) {
if (! _custom_isMyTheme()) {
return theme_file($variables);
}
$tpl = <<<HTML
<div class="inputFile" style="width:390px; height:36px;">
<div class="inputFileContainer">
<div class="inputFileField"></div>
<div class="inputFileButton">%s</div>
</div>
%s
</div>
HTML;
dpm($variables);//devel shows #required property as FALSE
return sprintf($tpl, t('Select'), theme_file($variables));
}
#required => TRUE
intheme_field_widget()
, and thendrupal_render_children()
in the render chain, and then indrupal_render()
it suddenly becomesFALSE
and remains thusly in yourtheme_file()
implementation. My initial guess is that theinput type="file"
isn't required but the hidden input is. I'll look a bit deeper into form.inc locally and see if I have more ideas...theme_file
, why would he need to declare a new theme function?