Entity reference field definition to auto create entities

Entity reference field definition to auto create entities

I have a field definition set up like below. I want Drupal to do all the heavy lifting for me, so my definitions are minimal and rely on Drupal defaults: $fields[$field] = BaseFieldDefinition::create(‘entity_reference’) ->setSettings([... read more
Entity reference field definition to auto create entities

Categories and brands

I have a product catalog that I would like to categorise into different categories (and subcategories). I would also like to have a grouping of the products by brands (which of course are orthogonal to the categories). The ideal thing is that a customer can search for... read more
Entity reference field definition to auto create entities

Pass multiple sets of variables to theme function

If I want to loop through multiple sets of theme variables in my custom theme template, how do I define them in my theme function and pass them to hook_theme? For instance, in my case, I’m generating an email body to send via drupal_mail(), and the body will... read more
Entity reference field definition to auto create entities

Set translated field

I’m having some trouble finding how to handle field translations in the documentation. I have a requirement to keep certain fields in English and Japanese. I periodically have to update nodes and taxonomy terms programmatically. I’m doing this with a... read more
Entity reference field definition to auto create entities

Checkboxes, Radios, ‘select or other’ wont render inside table select element

I want to render elements of type checkboxes or radios inside tableselect, but what I get are empty html tags. Textfield and select type elements render fine. Basically this renders fine. $tableSelectTesting = array( ‘#type’ => ‘select’,... read more
Entity reference field definition to auto create entities

Enable CKeditor on Webform’s textarea

I’m trying to create a contact form supporting HTML formatting with Webform and CKEditor. So I created a new webform with a single field of type Textarea and now I have a simple webform with the basic textarea. How can I enable rich text formatting on this form?... read more
Entity reference field definition to auto create entities

Remove entities programmatically from view results before pager is generated

I want to remove certain entities from the view results (Views core module), before the view’s pager is generated. By now I am doing it in hook_views_post_execute(). The problem here is, that the number of results on the view pages is different then. There... read more
Entity reference field definition to auto create entities

Drupal database not found after running update.php

after installing a module I run update.php and then click take me to front page or take me to admin pages the page takes a while to load and eventually gives me the following error: PDOException: SQLSTATE[HY000] [2002] No route to host in lock_may_be_available() (line... read more
How to disable a file upload button for anonymous users?

How to disable a file upload button for anonymous users?

I’ve created a commerce add to cart form with a file upload field. The user can use this to upload a logo but I don’t want anonymous users to be able to do this. I can see that the file module uses ajax to handle the upload but I can’t see how you... read more
Entity reference field definition to auto create entities

Change field settings for text field from plain to formatted while data exists

anyone know of a quick example of how to change the field settings for a text area (plain) to formatted and set the input formatter (or maybe it will use default)? Will this require a resave of all the data or can it just be changed for the entity type? I currently... read more
Entity reference field definition to auto create entities

How to hide the submit button on a node add/edit form page within which a entity reference select list has no valid option?

Registration content type has a required entity reference field. The widget of this field is a select list, the options are populated with a views entity reference display output. I want to hide(unset) the submit button if the views entity reference display returns no... read more
Entity reference field definition to auto create entities

InvalidArgumentException… Class not Found in Custom Module

Here is the simplified error: InvalidArgumentException: Class “DrupalprepcartControllerPrepCartController” does not exist. in DrupalCoreDependencyInjectionClassResolver->getInstanceFromDefinition() (line 24 of... read more
Entity reference field definition to auto create entities

Multiple domains with a language each

We’ve setup that english language points to an english domain, and for spanish we have a language. The spanish one is simply a symlink to the english code base. When translating nodes, I am being redirected to the Spanish domain when changing a spanish node, and... read more
Entity reference field definition to auto create entities

Trying to pass id to the ajax callback function, keeps overwriting, how to solve this?

I created a form which have a lot of images and a delete button on every each one of them. I used ajax to create a callback function which would delete the image. Here is part of my form: foreach($result as $key=>$some){... read more
CKEditor table td style not showing in frontend

CKEditor table td style not showing in frontend

I use CKEditor (WISYWYG editor) to edit text and HTML for my Drupal project. I want to edit an HTML table and try to horizontally align text in a table cell <td> to the right. My steps: select the text in the table cell right+click > Cell > Cell properties... read more
Entity reference field definition to auto create entities

How to use drupal_add_library with a module?

I’m new to Drupal and don’t really understand how to set up drupal_add_library. I’ve made a simple module that links out to a .js file. However, this .js file depends on a couple of generic functions. I’ve put this generic functions in a... read more
Entity reference field definition to auto create entities

How do I add a meta tag in inside the <head> tag?

How can I add the following meta tag inside the <head> tag? <meta http-equiv="X-UA-Compatible" content="IE=edge" /> I am trying to add it to a Drupal 8 site. read more
Entity reference field definition to auto create entities

Accessing Content: Path field within views_view_unformatted TWIG template

I have a view that has the fields: Content: ID, Content: Title and Content: Path. In my views-view-module.html.twig file I can access the fields via the following: {{ item[‘#row’]._entity.id }} {{ item[‘#row’]._entity.title[0].value }} But I... read more
Entity reference field definition to auto create entities

How do I find services?

What is the best way to find right service for dependency injection? Googling is not efficient yet. For example I spent quite long time figuring out that if I need current request passed to constructor by DI I have too use:... read more
Entity reference field definition to auto create entities

Action links available options / caching

I have some action links defined in module.links.actions.yml which uses a custom “create entity” route. For entity creation I set up some restrictions and at some point the access is denied. The problem is that whilst the access to the page is denied, the... read more