How to insert value to taxonomy on custom form submission I have a page where admin can add a new hospital name to the site, search for the hosiptals and view all the hospitals in a tabular format. This is done by writing custom module and form.

What I now need is to add the value of the newly created hospital to a taxonomy term "hospital". So that I can use this taxonomy term reference in multiple content types.

If admin adds hospital-1 and hospital-2 to the site using custom form, on form submission these should automatically get added to the taxonomy term.
To add taxonomy term in form submission, get all inputted term values and those to Vocabulary you need.

use Drupal\taxonomy\Entity\Term;
$categories_vocabulary = 'EXAMPLE'; // Vocabulary machine name
$categories = ['test 1', 'test 2', 'test 3', 'test 4']; // List of test terms
foreach ($categories as $category) {
  $term = Term::create(array(
    'parent' =&gt; array(),
    'name' =&gt; $category,
    'vid' =&gt; $categories_vocabulary,
))-&gt;save();