I have an entity with an editable field which the user can change. I used hook_entity_presave() to save this value to the database.
I also wanted to prevent the user from entering multiple inputs by disabling the field after input and replacing the submit button with a clear button to remove their input and present an empty field once again, so I naturally used hook_form_alter().
The problem is that hook_entity_presave() doesn’t run and save my value, instead only the form alter runs, not correctly may I add.
I’m pretty sure it worked fine a couple of days ago and I did not change anything within those functions.
function mymodule_form_alter(&$form, $form_state, $form_id) { if ($some_condition == TRUE) { $form['field_input']["#disabled"] = TRUE; unset($form['submit']); $form['clear_button'] = [ '#type' => 'submit', '#value' => t('Remove'), '#submit' => 'reset_form' ]; return $form; }
What goes wrong?