Custom Save and Unpublished button for node
You can't use

 $entity-&gt;set('moderation_state', 'submitted');


if you don't have Content Moderation core module enabled

Also make sure you declare the usage of FormStateInterface somewhere in your .module file

use Drupal\Core\Form\FormStateInterface;


Also look in your error logs found in admin/reports/dblog for other possible errors