I am trying to theme out the node add/edit form for a custom content type (ex. ‘album’). I have created a form_alter hook in my theme
function mytheme_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
switch ($form_id) {
case "node_album_form":
$form('#theme') = ('node_album_edit_form');
break;
that correctly intercepts the node add/edit form and passes it to my theme hook which also finds the correct twig template.
function mytheme_theme() {
return array(
'node_album_form' => array(
'template' => 'node_album_edit_form',
'path' => Drupal::theme()->getActiveTheme()->getPath() . '/scss/templates/album',
'render element' => 'form'
),
};
}
in my twig file, ‘node_album_edit_form.html.twig’, I can confirm that changes here alter only the album add/edit form and that I can remove elements, ex:
{{ form|without('advanced', 'footer', 'actions') }}
What I cannot do but would like to is place the form fields where I want them, ex:
<div class='myfancydiv album-title-field'>{{ field_album_title }}</div>
<div class='myfancydiv album-artist-field'>{{ field_artist }}</div>
because I’m not using the right reference to the field. I’ve tried:
{{ field_album_title }}
{{ form.field_album_title }}
{{ album_title }}
to no effect. Anyone have a working example of this?