I have an eform printing out some fields. I want to create a module to change layout of the eform using hook_theme(). So, I have hook_theme() in my mymodule.module file and mymodule-form.html.twig file in template folder. Since I'm testing it, I only want to print out one field. But it prints out all of the field which seems like hook_theme() or twig is not working. Here's my code.
mymodule.module
<?php
/**
* Implements hook_theme()
*/
function gq_theme($existing, $type, $theme, $path) {
return array(
'gq_form' => array(
'variables' => array(
'first_name_field' => $form['field_first_name'],
),
),
);
}
/**
* Prepares variables for the gq form template.
*
* Default template: gq-form.html.twig.
*/
function template_preprocess_gq_form(&$variables) {
$variables['first_name_field'] = $form['field_first_name'];
}
mymodule.html.twig
{{ first_name_field }}
Also, I only have two files, mymodule.module, mymodule.info,yml, templates/mymodule-form.html.twig in module directory. Are there some necessary files?