The ajax callbacks are pretty nice to work with, I'd like the same for non-js forms.
This is meant to help with the htmx initiative, Ideally we would not have different code path to handle ajax and non-ajax forms.
Add a new #callback
render array key, that is used whenever _trigger_element_name
and _trigger_element_value
corresponds.
// for an htmx-submitted form we can just do:
$form['type'] = [
'#type' => 'select',
'#title' => 'Type',
'#empty_value' => '',
'#options' => [
'a' => 'A',
'b' => 'B',
],
'#default_value' => $type,
'#callback' => [static::class, 'test'],
];
// for a non-js form
$form['test'] = [
'#type' => 'button',
'#button_type' => 'submit',
'#name' => '_triggering_element_name',
'#value' => 'TEST!',
'#callback' => [static::class, 'testsubmit'],
];
// We can also trigger a callback from an other element, similar to #ajax 'trigger_as'
$form['test'] = [
'#type' => 'button',
'#button_type' => 'submit',
'#name' => '_triggering_element_name',
'#value' => 'type',
];
Active
11.0 🔥
forms system
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.