I’m trying to add a form to the admin sales order create page.
When I create a new order i cannot see my form but if i refresh the page the form is available.
i added code to sales_order_create_index.xml (Vendor and Module names changed)
<referenceBlock name="data" template="Vendor_Module::order/create/data.phtml"/>
<referenceContainer name="data">
<block class="VendorModuleBlockAdminhtmlOrderCreateGeodisCarrierService" template="Vendor_Module::order/create/geodis_carrier_service.phtml" name="geodis_carrier_service_block"/>
</referenceContainer>
where data.phtml is basically the original file with one additional line that loads the block
<?= $block->getChildHtml('geodis_carrier_service_block') ?>
the geodis_carrier_service.phtml code:
<section class="admin__page-section geodis-info">
<div class="admin__page-section-title">
<span class="title"><?= $block->escapeHtml(__('Geodis Information')) ?></span>
</div>
<div class="admin__page-section-content">
<fieldset class="admin__fieldset " id="geodis-carrier-service">
<legend class="admin__legend"><span><?= $block->escapeHtml(__('Geodis Carrier Service')) ?></span></legend>
<br>
<div id="carrier_service_block" class="edit-carrier-service">
<div class="order-history-block">
<div class="admin__field field-row">
<div class="admin__field-control">
<select name="order[geodis_carrier_service]" id="geodis_carrier_service" class="admin__control-select">
<?php foreach ($block->getCarrierServices() as $value => $label): ?>
<option value="<?= $block->escapeHtmlAttr($value) ?>">
<?= $block->escapeHtml($label) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
</fieldset>
</div>
from
https://stackoverflow.com/questions/17049033/magento-add-block-to-sales-order-create
Magento 2 : Custom template file is loading after refreshing the page only?
Custom Module’s template override not loading initially unless the page is refreshed
Adding new block in admin order section
From the above links I understand that I also need to add some code to this files:
sales_order_create_load_block_data.xml
sales_order_create_load_block_items.xml
to make it load the form right from the start and not only when i refresh the page
but i just don’t understand what code should those files contain.
Has anyone built a module like this and can prodive insights ?