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?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communitydrupal_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);