Insert data from form to drupal database

pretty new to drupal and I am running into a problem trying to insert data into my database from a form.

The form itself is generated from js in my theme folder,

$  ('.register')   .find('.title_block')   .addClass('reg-details')   .append('<div id="emailRegister" class="modal"><div class="modal-content">      <span class="close">&times;</span><br><br><p>We have detected that you        are on a mobile device. It can        take up to 2 minutes to fill out the required profile.</p><p>If you        would like to finish this        profile at a later time, we can email it to you.</p><p>Otherwise,        select Close to proceed!</p>        <form method="post" action="/register.php" enctype="multipart/form-        data">First name:<br><input        type="text" class="emailFields" name="firstname" value=""><br>Last        name:<br><input type="text"        class="emailFields" name="lastname" value=""><br>Email:<br><input        type="email"        class="emailFields" id="regEmail" name="email"><br><input type="submit"        value="Submit"><br>        </form><button type="submit" id="closeModal"        style="background:grey">Close</button>')   .insertBefore('.lms-main-container'); 

The action page is in the root of my folder

<?php  require 'vendor/autoload.php';  use Drupal\docebo_login\FormaNotification;   $  email = $  fname = $  lname = "";  $  email = $  _POST["email"];  $  fname = $  _POST["firstname"];  $  lname = $  _POST["lastname"];   if ($  email == "" || $  fname == "" || $  lname == "") {    header("Location: http://example.com");    exit();  }   $  noti = new FormaNotification();   $  result = $  noti->getRegister($  fname, $  lname, $  email);   $  auth = array('api_key' => 'some=key=here');   # The unique identifier for this smart email  $  smart_email_id = 'email-id';   # Create a new mailer and define your message  $  wrap = new CS_REST_Transactional_SmartEmail($  smart_email_id, $  auth);  $  message = array(      "To" => $  email,      "Data" => array(          'variableName' => 'variableNameTestValue',          'x-apple-data-detectors' => 'x-apple-data-detectorsTestValue',          'href^="tel"' => 'href^="tel"TestValue',          'href^="sms"' => 'href^="sms"TestValue',          'owa' => 'owaTestValue',          'role=section' => 'role=sectionTestValue',          'style*="font-size:1px"' => 'style*="font-size:1px"TestValue',      ),  );   # Add consent to track value  $  consent_to_track = 'no'; # Valid: 'yes', 'no', 'unchanged'    # Send the message and save the response  $  result = $  wrap->send($  message, $  consent_to_track);  if ($  result) {    header("Location: /");    exit();  } 

As you can see I call a function from my theme’s modules here is the function

   public function getRegister($  fname, $  lname, $  email) {          return parent::insertRegister($  fname, $  lname, $  email);     } 

Which Then passes the variables on to this function in its parent

 public function insertRegister($  fname, $  lname, $  email) {        db_set_active('docebo');        $  this->setConnection('dev-db');       $  result = $  this->getConnection()->insert('register')        ->fields([          'fistName' => $  fname,          'lastName' => $  lname,          'email' => $  email,          'dateAdded' => REQUEST_TIME,        ])        ->execute();        db_set_active();      } 

Now I could be naive but I thought that would be it. But When I submit the form all I get is an 500 error notice. When I remove the insert from the form action, the form works as expected.

I tried getting a better error message to help me out ie checking my settings.php to make sure error reporting was on verbose, even tring to set it in my ini.php or putting the

 ini_set('display_errors', 1);  ini_set('display_startup_errors', 1);  error_reporting(E_ALL); 

on the form action page itself and still get nothing. There also appears to be nothing in my logs as well. So I am pretty stumped. Any help at all would be greatly appreciated. Thank you!!!

Migrate date field from csv to Drupal 8 using format_date

have been trying to import the date fields from a CSV file to Drupal 8 using format_date function. followed these two answers Import a date from CSV to Date field How to convert year to date with Migrate

but didn’t work for me. it keeps translating everything into 1969/12/31 19:33. Does anyone know why?

here is my YAML file where field_date is machine name of my content type date field, and Date is the field name in CSV. and the date format in CSV is like 12/22/12 12:22

field_date: plugin: format_date from_format: 'm/d/y H:i' to_format: 'Y-m-d\TH:i:s' source: Date

Migrate date field from csv to Drupal 8 using format_date

have been trying to import the date fields from a CSV file to Drupal 8 using format_date function. followed these two answers Import a date from CSV to Date field How to convert year to date with Migrate

but didn’t work for me. it keeps translating everything into 1969/12/31 19:33. Does anyone know why?

here is my YAML file where field_date is machine name of my content type date field, and Date is the field name in CSV. and the date format in CSV is like 12/22/12 12:22

field_date: plugin: format_date from_format: 'm/d/y H:i' to_format: 'Y-m-d\TH:i:s' source: Date

How to make Drupal 8 aware of entity schema changes that are managed external to Drupal

Though it’s ideal to centralize entity and schema management together within Drupal, there are possible use cases where the two must be managed independently:

  1. Drupal entities that are based on tables in an external DB
  2. Manual schema updates for tables with exiting data that are considered unsafe from a cross-DB support perspective, but may otherwise be safe in controlled situations (e.g. increase varchar length on mySQL).

Our case is specific to #1. We have Drupal entities based off tables in an external DB (using base_table = "dbname.tablename" convention), and the related schema is managed exclusively by another platform. This means that when schema changes are deployed externally we need to update the relevant entity definitions and installed schema definitions in Drupal without triggering the actual schema updates themselves (e.g. no CREATE/DROP/ALTER TABLE... calls). The best way to tackle this problem has always been a bit unclear, and some of the new constraints introduced in 8.7.x seem to cloud the matter even further.

It seems that there are several Drupal-specific layers that need to be navigated here, including the entity definition, the entity storage definition, the last installed schema definition, the actual schema management API and various caches. The interplay between these layers had been difficult to pin down.

Possible Approaches

Some solutions proposed in forums involve manual manipulation of each API layer and often ad-hoc workarounds (direct updates to key_value DB records) that seem quite questionable. Examples are here, here and the “Updating an existing entity type” notes here. There also appears to be some discussion around overall limitations in field-specific schema updates here.

Some relief may come in the form of the EntityDefinitionUpdateManagerInterface which seems to serve as a central place to abstract these various layers away, but it’s not clear which methods operate purely on storage/schema definitions and not the actual DB schema itself. For example, I have had some success (re)using the ::installEntityType() method to deploy changes after externally updating the DB schema, updating the related Drupal entity definition and then running:

$  entity_type = \Drupal::entityTypeManager()->getDefinition('my_custom_entity_type'); $  entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager(); $  entity_definition_update_manager->installEntityType($  entity_type); 

This seems to update the related entity/field storage definitions and the schema definitions and does not seem to alter the DB schema (I guess because the related table is detected as already existing). But given that this method is documented for once-off use (not ongoing re-install use) this feels like “off-label” use with unpredictable side-effects.

I also suppose that a custom entity storage definition could be justified to deal with all this, but I assume that would require re-defining or re-wiring quite a few dependencies (notably the low-level SQL management) that otherwise work well with the native entity storage.

Final Question

So what is the best practice way to make Drupal aware of externally managed schema updates that impact Drupal entities?

I have a feeling that fully understanding this also requires a good explanation of how APIs used to manage Entity/Field definitions/storage are independent (or not) from core schema management tools like the Schema API and hook_schema().

Drupal Commerce 2 Receipt Email only shows Billing and Shipping data when an order is placed as an admin user

I have triple checked all the User Permissions on admin/people/permissions. All checked permissions for under Commerce are checked with the exception of those that have the “Warning: Give to trusted roles only; this permission has security implications.” warning.

I replaced the custom commerce-order-receipt.html.twig with the original one used in Commerce2 with no luck as well.

Any further debugging tips and suggestions are helpful as I am newer to the Drupal world. Thank you!

Drupal panel not able to edit

I have a drupal 7 panel node. I have few regions in panel content. I am not able to edit any one of those regions.

In Chrome console, I can see java script errors as below.

Refused to apply style from ‘http://localhost/node/32/FONT_AWESOME_44’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled. flexible-admin.js?ptcf02:13

Uncaught TypeError: Drupal.flexible.splitters[i].fixHeight is not a function
at Object.Drupal.flexible.fixHeight (flexible-admin.js?ptcf02:13)
at Object.attach (flexible-admin.js?ptcf02:44)
at Object. (drupal.js?ptcf02:112)
at Function.each (jquery.min.js?v=1.7.2:2)
at Object.Drupal.attachBehaviors (drupal.js?ptcf02:110)
at HTMLDocument. (drupal.js?ptcf02:593)
at o (jquery.min.js?v=1.7.2:2)
at Object.fireWith (jquery.min.js?v=1.7.2:2)
at Function.ready (jquery.min.js?v=1.7.2:2)
at HTMLDocument.B (jquery.min.js?v=1.7.2:2)

Can you please suggest me how can I resolve this issue?

How to skip migrating certain entities in Drupal 8 Migration?

How do I skip migration for some entities? To simplify, let’s say I have a node type Cow with a field called field_moo. If field_moo is empty, I don’t want to migrate that nodes to the target. What can I put in my migration YAML to check if field_moo is empty, and if so, to skip the migration for that node?

Is there a source plugin that is similar to the process plugin skip_on_empty?

This is for a Drupal 7 to 8 migration.

Is Drupal 8 truly a secure enterprise solution when compared to Laravel?

I know this might seem like an open-ended question, but it is really specific. My concern is regarding version updates. The scenario is as follows:

  1. A core drupal update is released
  2. I have “update manager” set to remind me of updates 1 per day
  3. I receive a notification at 7AM of a core release that came out at 1AM

In this scenario, a hacker had 6 hours to look at the release notes and attempt to use the security issue to hack my site. This basically means that any Drupal site that can’t be insta-updated, is at risk. And I doubt you will be able to insta-update it ever. You will always be a few seconds behind.

Laravel differs in that it doesn’t have so many insecure parts. Or at least, I think so. You are still installing packages using composer, but as far as I know, those packages are generally more secure than Drupal modules. Perhaps someone can confirm that? Or confirm if the same concerns are applicable in Laravel’s case?

So my question is two-part:

  1. Do you agree that Drupal 8 is less secure than frameworks like Laravel because of the core updates and how the release notes can be used to hack just about any site?
  2. Is Drupal safe to use for something where security is absolutely crucial? (For example, would you build a Bitcoin exchange using Drupal? Why not?)

Thanks!

How can I display custom data from the Drupal DB in a View?

I’m working to create a new website in Drupal 8 and cannot figure out how to reference custom table data within a View.

Specifically, I have a script that is taking data from an external DB and populating it into my Drupal DB into custom tables. How can I allow Views to see this data?

In Drupal 7 I have experience using the Forena module and the Data and Schema modules to accomplish same DB and external DB references, but what I’m finding is that support for these three modules in Drupal 8 appears to be lacking, making me think that there is a better way to do this in D8 that everyone knows about but me. 🙂

I’m not sure if I’m just not researching correctly, but I’m unable to find a clear answer about how to go about obtaining this functionality in Drupal 8. Drupal 8 is so different and I’m not sure if I should be looking for a contributed module or if this is something I would code directly.

Hopefully someone can point me in the correct direction?

Installing security updates on Drupal 7.3.4 hosted on Windows 2012 R2 IIS 8.0

I am brand new to Drupal. I have noticed that there are security updates avaialble for my version. When I select the first item requiring an update and select download I get the following error HTTP error 0 occurred when trying to fetch https://ftp.drupal.org/files/projects/mimemail-7.x-1.1.tar.gz.

I would appreciate it if someone could assist in identifying why this issue is occurring and point me to any documentation regarding installing security updates on Drupal running on IIS 8.0