I have built a custom form (in its own module using FORM API) and have exposed this form also as a block using Plugin API.
I can add this form fine to page and get it to render using Block Layout but it doesnt appear in the correct place.
I am trying to get it to appear in the main page content of a Page View
which has a Header and Footer. The form seems to appear after the footer content, even after shifting the block around in the block layout.
So now I have been trying to use the various view template hooks by loading the form via the snippet:
$block = \Drupal\block\Entity\Block::load('auctioncataloguerequestform');
$block_content = \Drupal::entityTypeManager()
->getViewBuilder('block')
->view($block);
$variables['form_auction_cat_request'] = $block_content;
auctioncataloguerequestform
is the machine name of the "form block" added to Block Layouts (Its in the content section, but disabled)
But in XDebug I cannot find the form_auction_cat_request
variable and {{ form_auction_cat_request }}
renders nothing.
Hooks I tried using where: template_preprocess_views_view
, template_preprocess_views_view_field
and template_preprocess_views_view_unformatted
At the moment I am simply trying to get the form to render but once this is done I then need to pass a string
variable which is a field of the view in question to be passed to the form.
Am I on the right track or completely missing the mark?
View screenshot