Replacing Ajax fails with the Form ID mismatch warning, even if the event is not executed the second time in Drupal 8

Enter image description here

Above the field is the paragraph field with two separate selection fields. Note : Business Rules Engine does not work with it.
Both field options are loaded from entity reference views.

Trying to create a dependent selection box with Drupal 8 Ajax Replace.

The replacement fails the second time, and the log displays the match with the form ID as a warning.

I tried a different approach by using HtmlCommand instead of ReplaceCommand and set the static ID for the child form element. By default, Drupal provides a dynamic ID for each form element. Also, if I try to change the item ID, it will not work by giving a Form ID mismatch warning.

  1. I tried to replace the entire form element by packing the wrapper with ReplaceCommand.
    / **
    * Implemented hook_field_widget_WIDGET_TYPE_form_alter ().
    * /
    function module_name_field_widget_entity_reference_paragraphs_form_alter (& $ element, & $ form_state, $ context) {

                    $ element['subform']['field_course']['widget']['#ajax']    = [
                  'callback' => 'get_competency',
                  'event' => 'change',
                  'method' => 'replace',
                  'wrapper' => '#edit-competency-'.$uuid_value,
                ];
    
    }
    
    
    
    Function get_competency (Array & $ element, FormStateInterface $ form_state, $ context) {
    
    
    $ triggeringElement = $ form_state-> getTriggeringElement ();
    $ value = $ triggeringElement['#value'];
    
    $ gt =  Drupal :: service (& # 39; generic_templates.utility & # 39;);
    $ options = $ gt-> getCompetency ($ value);
    $ options = ["_none" => "- Select a value -"] + $ options;
    $ wrapper_id = $ triggeringElement["#ajax"]["wrapper"];
    unset ($ triggeringElement["#value"]);
    unset ($ triggeringElement["#ajax"]);
    $ triggeringElement['#title'] = "Competence";
    $ triggeringElement['#prefix'] = & # 39;
    & # 39 ;; $ triggeringElement['#suffix'] = & # 39;
    & # 39 ;; $ triggeringElement['#options'] = $ options; $ triggeringElement['#default_value'] = NULL; $ triggeringElement['#field_name'] = "Field competence"; $ triggeringElement['#parents'] = [ "field_configurations", 0, "subform", "field_configuration", 0, "subform", "field_score", 0, "subform", "field_competency", ]; $ triggeringElement["#array_parents"] = [ "field_configurations", "widget", 0, "subform", "field_configuration", "widget", 0, "subform", "field_score", "widget", 0, "subform", "field_competency", "widget", ]; $ triggeringElement["#attributes"]["data-drupal-selector"] = str_replace ("course", "competence", $ triggeringElement["#attributes"]["data-drupal-selector"]); $ triggeringElement["#name"] = str_replace ("course", "competence", $ triggeringElement["#name"]); $ id = explode (& # 39; - & # 39 ;, $ triggeringElement["#id"])[0]; $ triggeringElement["#id"] = str_replace ("course", "competence", $ id); return $ triggeringElement; }
  2. I changed the ID of the element as a wrapper ID so that the form element itself now acts as a wrapper, and I used HtmlCommand. The idea is to replace only the entire Drupal-generated selection field (1st method).

use Drupal Core Ajax AjaxResponse;
use Drupal Core Ajax HtmlCommand;

                / **
* Implemented hook_field_widget_WIDGET_TYPE_form_alter ().
* /
function module_name_field_widget_entity_reference_paragraphs_form_alter (& $ element, & $ form_state, $ context) {

$ element['subform']['field_course']['widget']['#ajax']    = [
                  'callback' => 'get_competency',
                  'event' => 'change',
                  'method' => 'html',
                  'wrapper' => 'edit-competency-'.$uuid_value,
                ];

$ element['subform']['field_competency']['widget']['#attributes']['id']= & # 39; processing competence - & # 39 ;. $ uuid_value;

}



Function get_competency (Array & $ element, FormStateInterface $ form_state, $ context) {

$ triggeringElement = $ form_state-> getTriggeringElement ();
$ value = $ triggeringElement['#value'];

$ gt =  Drupal :: service (& # 39; generic_templates.utility & # 39;);
$ options = $ gt-> getCompetency ($ value);
$ options = ["_none" => "- Select a value -"] + $ options;
$ wrapper_id = $ triggeringElement["#ajax"]["wrapper"];

$ gt =  Drupal :: service (& # 39; generic_templates.utility & # 39;);
$ options = $ gt-> getCompetency ($ value);
$ options = ["_none" => "- Select a value -"] + $ options;
$ renderingField = & # 39; & # 39 ;;

foreach ($ options as $ key => $ value) {
$ renderingField. = "";
}

$ response = new AjaxResponse ();
$ response-> addCommand (new HtmlCommand (# #; # $ wrapper_id, $ renderingField));
return $ response;
}

GUI design – What is the best place for an information icon on a form?

Make the labels as clear as possible that no additional information is required. In some cases this is not possible. In this case, such an information symbol (probably a tooltip will open) may be helpful.

The overall layout affects where the icon should be placed. The info symbol near the label indicates the user context.
Option 2 looks more visually appealing at first glance, but at second glance you can see that the symbol is sometimes unrelated, for example: at the sex.
Option 3 may have the same problem and you are losing space for the input fields, which may be a problem on mobile screens.

So I would suggest going with option 1.

Another thought: I wonder what the information in your tooltips would look like, because the labels in your example are very clear. If you think about using the tool tips to give instructions for filling in the field (minimum number of letters, password rules, etc.), the tooltip is the wrong pattern. In this case you should enter the information below the field.

php – I can not send a contact form. The message "Wrong e-mail!" Appears when you click Send

I'm trying to set up a contact form, it did not have the code in PHP, just in HTML and in the action code of the HTML code it sent to the site https://mobirise.com/.

Example – HTML as it was:

After I created the code in PHP, I removed the link from the HTML code included in the action function (https://mobirise.com/) and replaced the setup
the page ("send_email.php") that I created with the code in php.

After I made these changes for the form to send the message to the site's email, I have the following problem: After I filled out the form and clicked on the message "False E-mail!" I clicked, I send the message. I need to solve this problem so that I can verify that the code is working in PHP and can send the information correctly to the site.

HTML – part of the code I changed:

          

HTML of the Fomulário:





& nbsp;

CONTACT US

Leave your name, email and get more information.

Form code – PHP





untitled document









<?
// isset checks if the Send - Submit button has been clicked on and triggers the email only if it is true

if (isset ($ _ POST['submit'])) {

// e-mail where you receive the message
$ recipient = & # 39; contato@belartsolucoes.com.br&#39 ;;

// get the form data ...
$ name = $ _POST['name'];
$ email = $ _POST['email'];
$ message = $ _POST['message'];

// headers preparing the message
$ headers = "MIME version: 1.0". " r  n";
$ headers. = "Content Type: Text / HTML; Character Set = utf-8". " r  n";
$ headers. = "From: Site " n" ";
$ headers. = "Reply to: contato@pmbasis.com.br". " r  n";
$ headers. = "X-Mailer: PHP /". phpversion ();


/ * below contains the data sent to the e-mail
registered to receive the form * /

$ body = "Sent form  n";
$ body = "Name:". $ name. " n";
$ body = "E-mail:". $ email. " n";
$ body = "message:". $ message. " n";


// send e-mail ... ->
$ answer = mail ($ recipient, $ headers, $ body, $ message);

// back to contact.html ->
header ("Location: index.php");
}
?>


App Windows – Arclab Web Form Builder 5.0.19 | NulledTeam UnderGround

Arclab Web Form Builder 5.0.19 | 2.8 Mb

Web Form Builder The HTML form creation software for Windows PCs to easily create e-mail contact forms and multi-page PHP forms. Create HTML forms on your PC and upload them to your own website.
Create the form on your computer
In case you do not want to get any further

Web Form Builder The HTML form creation software for Windows PCs to easily create e-mail contact forms and multi-page PHP forms. Create HTML forms on your PC and upload them to your own website.
Properties:
Create the form on your computer
Design forms in a visual environment
PHP script is running on your own website
Private and secure – no external data processing
Send the form data by e-mail to your e-mail address
Paste the form data into a MySQL database
Several submission tasks
Compliance with the GDPR in the European Union
No subscriptions and no recurring fees
Unrestricted form
Create online forms for your website without coding
Design online contact forms, registration forms, and other web forms in a visual environment without any coding or knowledge of PHP and HTML. Add the input elements required for your form and specify the data to be entered by the user. Just press a button and Arclab Web Form Builder will create the complete form code to process the submitted form data for you. The generated PHP script displays the form, sends the form data as an e-mail, or inserts the data into a MySQL database.
The Web Form Builder includes several design templates that contain a combination of matching input elements, colors, and spacing.
Use one of the supplied design templates or design it to your own specifications. The design of the form can be customized to allow seamless integration into your website.
The form is completely based on HTML5, CSS3 and Javascript. By using CSS in custom dialogs, the form can be customized without you being surprised. No external fonts or other external resources are required.
Operating system: Windows 7, 8 / 8.1, 10

DOWNLOAD
Nitroflare

When saving records in the form of a Laravel matrix, save only the last record

I am trying to save a matrix in Laravel, but it only saves the last record. I explain myself better:

I am doing a virtual classroom where I manage modules and classes. Within modules, there are different classes with their respective titles, descriptions, etc. In the end, the problem is that whenever I try to save all the data, only the last one is saved

Example:
If I store 3 modules and there are 1 classes in these modules, only module 3 and the second class of module 3 will be saved.

The code of my controller is as follows:

$ module = new module;
$ themes = new theme;
$ i = 0;

foreach ($ request-> nombremodulo as $ key) {


$ module-> course_id = $ request-> idcurso;
$ module-> name = $ key;
echo $ key "
"; $ module-> save (); $ j = 0; foreach ($ request-> title[$i] as $ key2) { // I understand the name $ filename = $ request-> file (& # 39; files & # 39;)[$i][$j]-> getClientOriginalName (); $ topics-> module_id = $ module-> id; $ topics-> title = $ key2; $ topics-> description = $ request-> area[$i][$j]; $ topics-> file = $ filename; $ topics-> save (); $ j ++; } $ i ++; }

Now if you ask if the data comes to the controller, if I make one dd () that shows me

Enter the description of the image here

I also "ordered" them in this way and specified their respective code
Examples in pictures

                                $ i = 0;

foreach ($ request-> nombremodulo as $ key) {

echo "
___________________________
"; echo $ key "
"; Echo "________________________________
"; $ j = 0; foreach ($ request-> title[$i] as $ key2) { Echo "class:" $ key2. "
"; echo $ request-> area[$i][$j] , "
"; Echo "========================================== ==============
"; $ j ++; }

The pictures are intended to illustrate how the data arrives at the controller and that they can see that the data arrives correctly The problem is that only the last "record" is saved, as I comment.