Skip to content
Snippets Groups Projects

Patch #12

Files
2
@@ -133,6 +133,18 @@ class WeightSelector extends FieldPluginBase {
'#value' => $this->field,
];
$form['actions']['submit_update_weight'] = [
'#type' => 'submit',
'#value' => $this->t('Update order'),
'#submit' => [
[$this, 'viewsFormSubmit'],
],
];
// @todo: This is still a problem, as it would also remove expected submits, e.g. from core or views_bulk_operations.
// What we need to achieve here or in the core issue (https://www.drupal.org/project/drupal/issues/3481777) is,
// that this additional button is never added for weight module itself!
unset($form['actions']['submit']);
$form['#action'] = $this->requestStack->getCurrentRequest()->getRequestUri();
}
@@ -140,6 +152,11 @@ class WeightSelector extends FieldPluginBase {
* {@inheritdoc}
*/
public function viewsFormSubmit(array &$form, FormStateInterface $form_state) {
// Ensure this is for us:
if ($form_state->getTriggeringElement()['#parents'][0] ?? '' !== 'submit_update_weight') {
return;
}
$field_name = $form_state->getValue('views_field');
if (!$field_name) {
return;
Loading