This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Adding a field programmatically to a content type

Hi,

I want to add a field of type entity_reference with unlimited values (programmatically) to a Content type. Can you please give me some examples? The ones that I found online are not very clear.

Thanks

After installing module, which provides custom entity, entity updates are needed

I have a custom module inside the custom profile and this module provides a new custom content entity, which is translatable. After site installation, the status page says that entity updates are needed for this custom entity and it needs to remove some translation-related fields like author, status, created, changed. If I apply these updates, nothing changes, everything seems to be working. These fields are all marked as translatable in entity class and the logic inside ContentTranslationHandler::getFieldDefinitions() shouldn't apply, although I think maybe it does somehow.

jsonapi 2.3 post a file always give me errors

I got the following case:
Drupal version: 8.6
jsonapi version: 2.3

now I am trying to POST a binary file (jpg image) to an api as follows:

Headers:

Authorization: bearer xxx
Content-Type: application/octet-stream
Content-Disposition: file; filename="xyz.jpg"
Accept: application/vnd.api+json

and the binary file data.

api url: {{BASE_URL_WITHOUT_TOKENS}}/api/products/deviceModel/110180fd-706e-473c-a362-bb3b7ffcfc31/field_device_model_image

Core patch not installing with composer

I'm trying to get composer to apply the following patch to core: https://www.drupal.org/files/issues/2019-05-29/2877994-140.patch

I've successfully applied patches for modules, but when I add the following to my composer file, nothing happens (tried running composer install, composer update, composer update --lock). I don't get an error, I don't get anything. 

My composer patch looks like:

Regarding hook_entity_delete

Hi,

I am trying to delete a field from a database named my_database. I am trying to use hook_entity_delete, in my .module file. I have tried to use something like :

function mymodule_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {

db_delete('text')
->condition('type', $entity
->getEntityTypeId())
->condition('id', $entity
->id())
->execute();
}

Sub select with hook_views_data

Hi there,

I have two tables both are in a non Drupal MySql database.

Table roster_data definition

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions