Increment or Decrement number of Fields Dynamically using Form API and Ajax
In this example, we will use a field to get tags list, the number of tags dynamic.
In this example, we will use a field to get tags list, the number of tags dynamic.
Example:$form['tagtest'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => 'Taxonomy Term',
];
<?php
namespace Drupal\mymodule\Controller;
Method 1. (Classical way)
Use a captcha system like Math captcha, Image captcha, reCaptcha of google....
NOTE: I don't know this is the best practice, anyway it's working !!!.
(#field_prefix and #field_suffix).
Example: Add/Remove 'test' Field depending on 'switch' field
Example : (Insert this line in to your form submitForm()
methode)
Redirect to the user page ( Redirection on form submit)$form_state->setRedirect('user.page');
Example : Display user login form on a page
$output = array();
$output['cache']['#disabled'] = TRUE;
$output['cache']['max_age']['#value'] = 0;