Draft: Resolve #3541597 "Ignore htmx dx"
Test for HTMX backend DX:
instead of using raw attributes use a kind of builder object and apply the result to the render array.
$form['config_name'] = [];
(new Htmx())
->post()
->swapOob()
->swap(HtmxSwapStyle::none)
->applyTo($form['config_name']);
When calling applyTo
everything is applied as-is to $form['config_name']['#htmx']
, so it becomes:
$form['config_name'] = [
'#htmx' => [
'post' => TRUE,
'swap-oob' => TRUE,
'swap' => ['style' => HtmxSwapStyle::none, 'modifiers' => new HtmxSwapModifiers()],
],
];
and this key is picked up in Renderer::render
just like #states
, and is finally transformed by HtmxHelper::processHtmx
and results in:
$form['config_name'] = [
'#attributes' => [
'data-hx-post' => '',
'data-hx-swap-oob' => 'true',
'data-hx-swap' => 'none',
],
];
Edited by Théodore Biadala