我想在覆盖html.html.twig
的树枝模板中渲染我的表单
树枝模板名为html--resume--myform.html.twig
在我的表单类中我有这个代码
public function buildForm(array $form,FormStateInterface $form_state)
{
$form['#theme'] = ['html__resume__myform'];
$form['candidate_name'] = array(
'#type' => 'textfield',
'#title' => t('Candidate Name:'),
'#required' => TRUE,
);
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Save2'),
'#button_type' => 'primary',
);
return $form
}
在我的resume.module文件中,我有这个自定义模板
function resume_theme() {
return ['html__resume__myform' => ['render element' => 'form']];
}
但我的表单未在html--resume--myform.html.twig
中呈现
或我的$ form变量未传递给html--resume--myform.html.twig
html--resume--myform.html.twig
位于模板文件夹