In a drupal8 module install file I have used drupal_execute() function like as follows

drupal_execute("content_copy_import_form", $form_state)

But this resulted in an error

Call to undefined function drupal_execute().

Any solution?

1 Answer 1


drupal_execute hasn't existed since Drupal 6.

In Drupal 8 you can submit a form programatically like this augmented example from ProgrammaticTest::submitForm:

$values = ['foo' => 'bar'];

// Programmatically submit the given values.
$form_state = (new FormState())->setValues($values);
\Drupal::formBuilder()->submitForm('\Drupal\form_test\Form\FormTestProgrammaticForm', $form_state);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.