Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [entities]

Nodes, comments, taxonomy terms, and users, using the terminology used since Drupal 7, are generally called "entities."

19
votes
3answers
39k views

How do I get the raw field value in a twig template?

myfield is a plain text field. {{ content.field_myfield }} renders the field with HTML markup and the field label. How do I render the raw value of the field? {{ content.field_myfield.value }} doesn'...
1
vote
2answers
370 views

Uploaded images deleted on save in Drupal

A certain content-type in my installation does not save images in it's gallery anymore. The image is being uploaded, registered in file_managed with status 0, and stored in sites/default/files. On ...
0
votes
1answer
359 views

Display blocked users to anonymous

How can I display blocked users in a template file? I have an Entity Reference field that I'd like to use to show anonymous users any blocked or active users added to the Entity Reference field. Is ...
12
votes
5answers
10k views

Add Fields to Field Group programatically

I have used "Field Group" module and created some groups in backend. Now i want to programatically add a field to the group. How can I do that. I am using Hook_form_alter, I have noticed that every ...
0
votes
2answers
373 views

How to hide field if blank

I have a view created which has a column 'Price'. I also I have another column 'Special Price' in the same view, but 'exclude from display' is selected. In views, click the price field > rewrite ...
0
votes
0answers
18 views

How do I retrieve media from a reference field?

Inside a node type, I have a reference field to target a media. With a db select, I need to load all related medias of the nodes. For this I use this code: $database = \Drupal::database(); $result = ...
10
votes
2answers
7k views

How to get the url of a file field of a given node?

$node->field_file gives me a FileFieldItemList while the first entry seems to be a FileItem. $node->field_file->getValue() gives me an integer (I guess the file id). How can I actually get ...
-2
votes
1answer
374 views

How can i hide a view field before it is rendered on page in drupal 8 [on hold]

I need to hide a view field where display mode is teaser.I need to exclude it before it is rendered in page based on some condition.
1
vote
1answer
374 views

How do I access the first value of a multiple value text field using replacement patters inside a rule?

For example, lets say I have a list of objects each stored as separate values of a text field. How would I access the individual values? I have tried using delta and I have tried using entity token ...
1
vote
2answers
364 views

Default image is not displayed while creating a node

I have created one content type, and also created one field named as "Preview Image". The type of this field is file and widget type is Image. For the Default Image I have uploaded one image which ...
0
votes
2answers
371 views

Change HTML output of View

I have a View which displays products. The fields shown are altered via mymodule hook, and I want to add div's and h3, etc., when I find an apropriate field value. (I tried with adding style to the ...
0
votes
1answer
378 views

Remove field attributes from form or custom form using hook_form

How to remove the field attributes from form in hook_form_alter. like <input type="text" class="form-text required" maxlength="255" size="60" value="" name="title" id="edit-title"> EX: ...
0
votes
0answers
14 views

How to programmatically add fields to a node through a module

I've followed a tutorial here about adding a field to every taxonomy and node and I'm getting an error on installing it. I can get the field, widget and formatter to work, just can't get it to install....
0
votes
1answer
372 views

Theme file upload form element

I want to theme all the file upload fields on my site but I don't know how to name the template file. I want to alter the form-element.html.twig file but as I have multiple file fields I don't think ...
0
votes
1answer
371 views

Add field to an entity_view for dispaly in a tapir table in ubercart

In the simplest terms I am trying to add a 'vendor' column to the order view table in Ubercart which will display the author of each line item product. Below is the table of interest. I have hacked ...
0
votes
1answer
381 views

How to get menu tree from a node to build a customize breadcrumb?

I would like to build a custom breadcrumb based on node relation from entity reference. For example there is a book node that has menu hierarchy: Book |-chapter 1 |--sub chapter 1.1 |---sub sub ...
1
vote
1answer
385 views

How to use the same EntityListBuilder for entity A and an extended version B

I have used the content entity example coming from the example project. This example define a Contact entity. Next I have extended this Contact class in an Artist class with some added fields (let ...
6
votes
2answers
3k views

getvalue() of multiple values field return only the first value

I added a new field in the field manage user page. This is a sample integer multivalue field. (we can enter several integer) I edited the profile of the admin user. I added (and save) some values in ...
1
vote
1answer
377 views

Theming a Fieldable Panel Pane — should I define a View Mode?

I added a Link field to Panopoly's Image fieldable panel pane, but I need to theme it so the link is silently wrapped around the image rather than displayed textually underneath. It also needs to be ...
0
votes
0answers
15 views

Get the field for a value of a “List (integer)” field using entity_load()

I am trying to get the label for a value of a List (integer) field using entity_load(). With the code I am using, I'm able to get the field key with $flagging->field_form_status['und'][0]['value'],...
0
votes
1answer
14 views

Get Entity ID when is saved

I need to capture the entity_id when the entity is saved. The ID will process and insert in a custom field. I use hook_entity_presave(), but when is a new entity the ID is void. Is there any way to ...
1
vote
4answers
626 views

How do I increase the length of a text-field with saved values?

I have a multi-value text-field, projects. Its length is 4, and I would like to increase it to 255, but there are values saved in the database for that field. How can I increase its length?
0
votes
1answer
378 views

How to set “Entity has Field” when the Rules Event is unrelated to the entity?

In Rules, I am trying to update/calculate a field in the User's account upon completion of a commerce payment. The condition data selector obviously only wants to populate commerce related fields, ...
0
votes
1answer
23 views

Custom Entity Type and Bundle Creation

I've been building custom entities for a while now, but have been using the entity construction kit (eck) to build them. This has limitations as it requires you to #1 depend on the package for new ...
0
votes
2answers
546 views

Render Date Range on node template

I'm trying to render both start and end date on a node template in Drupal 8 from the Date range field from the content type. I've tried multiple ways to no avail. -- Only shows start date -- {{ kint(...
2
votes
2answers
469 views

Create a countdown using an existing date field

I have a date field field_date_subscription in each node on my website. Can I use it to create a countdown without necessarily creating a new field field_countdown? With many modules I've seen I ...
1
vote
1answer
62 views

Disable field date and checkbox

i've trying disabled input field of type date and checkbox in hook_form_alter with above code: $key = 'field_name'; $form[$key]['widget'][0]['value']['#attributes']['disabled'] = true; $form[$key]['...
0
votes
1answer
382 views

Alter title link in taxonomy view mode

Under /admin/structure/taxonomy/my_vocabulary/display/entity I've got a view mode "entity". For this view mode, I would like to alter the way the link in the title field is built (the title is ...
2
votes
1answer
247 views

How can I change a field cardinality?

I have two content types: Person and Office with existing content. The Person content type has an entity reference field to Office nodes, which only allows a single reference. I need to change this to ...
2
votes
2answers
385 views

Views: Display a key from unserialized data field

I really don't understand how the "User: Data" field works. Couldn't find any documentation of this. I want to set the Display format to "A certain key" to output the identifier value from this ...
0
votes
1answer
25 views

Field weight ignored on buildForm()

I need to set the $form['langcode']['#weight'] to -251. I tried also to access the widget weight. But the position weight still remains on bottom of the form. Why is that? I tried: //form field ...
0
votes
1answer
420 views

Show/hide fields bij adding content based on checkbox

Is there a way to hide a specific or specifics fields in Drupal when you create content until you checked a checkbox? Now it looks like this: I need something like this: But I need some checkboxes ...
0
votes
1answer
393 views

Remove order from Field Collection set in form

I am using the Field Collection and Field Collection Fieldset modules to group a set of elements in my form. But what i see in the form is an Order column for the fieldset items, which i would like to ...
0
votes
1answer
393 views

Entityform (block) redirect not working

The redirect field within entityform doesn't seem to have any effect. I'm using the entityform block module, if it makes any difference. I have also tried using hook_form_alter to copy to default ...
1
vote
1answer
386 views

Pass data to hook_entity_insert

How can I pass data to hook_entity_insert() given that the arguments it takes are fixed? I'm writing to the database during entity save, and need to be able to pass some data in this hook.
2
votes
1answer
391 views

How to populate a node reference field that has multiple values?

I'm using the rules to create a new node upon changing the current node publishing status to published. And populate some field based on the updated node field. Im trying to populate a node reference ...
0
votes
2answers
554 views

Admin can create content but regular users can't

On my D7 site, for /node/add/[type], admin users can successfully add content, but merely "authenticated users" cannot. When a non-admin user tries to add content, the body and taxonomy fields do not ...
0
votes
1answer
395 views

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 }} {{ ...
1
vote
1answer
394 views

Setting up a date field to require an end date

I'm attempting to create a custom content type for a module via hook_install. When I create a date type (from Date module), I want it to require an end date (there's a checkbox when you're setting up ...
-1
votes
2answers
296 views

'Edit Own Content' permission missing in custom entity

I have generated a custom entity using Drupal Console. drupal generate:entity:content The entity doesn't have the permission edit own content which we usually have in node types etc... The entities ...
1
vote
1answer
395 views

Conditional Fields with multiple conditions

I am using Conditional Fields module. I need some guidance when setting dependencies for multiple fields (accepting unlimited values). Here is the situation: In my entity form I have two fields: ...
0
votes
1answer
405 views

Using Entity metadata wrappers to change field value under hook_node_insert()

I am trying to change a field value inside both hook_node_insert() and hook_node_update() using EMW. It actually changes the original $node object that is passed to these hook functions but the change ...
-2
votes
1answer
18 views

How can I import a CSV file to custom entity created using ECK module?

I have created a custom entity type using ECK module. I want to import a csv file with data to my custom entity. How do I do this?
1
vote
2answers
401 views

How to use Rules to send an eMail containing a list of nodes with a selected value in a field?

I try to send a list of nodes with certain value in a specific field via the Rules module. This is what I have so far: Event: "After updating existing content of type MyContentType" Conditions: "...
0
votes
1answer
392 views

hook_field_formatter_view does not get called

I have a custom field, that hooks into profile2 and saves it's value in user data blob. Everything works fine, except the hook_field_formatter_view, that does not get called for a reason. As a result, ...
0
votes
1answer
395 views

Drupal 7/Profile2: how to add fields and hide them from client?

I added fields to a Client profile using Profile2, such as first name and last name. But I added another fields, let's call it "Assigned Consultant". But the "Assigned Consultant" field... I don't ...
0
votes
2answers
31 views

How to print an entity bundle field from one with multiple values

Struggling to find the answer to this. I have an entity called "school objects" which has a bundle called "homepage". One of the fields attached to this is called "Hero banners" and it allows multiple ...
0
votes
2answers
399 views

Define available default colors for Color Field programatically

I use the Color Field as a field in a custom module from where I create the content type programatically. By default the available colors are defined at this hook: color_field_field_settings_form in ...
0
votes
0answers
21 views

Datetime wrong type in database

i'm triying to create an custom entity, to store data i'm creating a schema through BaseFieldDefinition (or some near). The problem is that some fiels of type datetime are created in the database with ...
0
votes
1answer
405 views

Adding custom field while migrating

I am trying to merging content types while migrating to drupal 8 from drupal 7 and at the same time differentiating them with the taxonomy terms in D8. E.g. The content types from D7 i.e. Article, ...