Tagged Questions
0
votes
1answer
16 views
How do you add a conditional to check if the Node object exists?
I have the following code, but how do I add a conditional to check if the menu_get_object() is grabbing a node object or not? Im mainly using this in my contextual filter in views and its throwing an ...
0
votes
1answer
186 views
Pre-populate default values into a form to edit a new entity
In a Drupal 7 site, I have created a new entity called "atomyx_portal_metadata". This entity works great in all respects. I allow people to define their own entity types (much as you can create your ...
1
vote
0answers
89 views
When should I use hook_field_attach_presave(), and when hook_entity_presave()?
I was looking for a way to act on entity fields before they are saved, and I have noticed the following about hook_field_attach_presave(), and hook_entity_presave():
They take the same parameters, ...
0
votes
0answers
116 views
Rendering all fields of an entity (i.e. viewing the entity)
I am trying to render all of the fields attached to a custom entity. This will be used for "viewing" entity, like you would view a node or a user, etc.
I first tried to use field_attach_view:
...
0
votes
1answer
244 views
Minimum entity properties for field_attach_update()?
Question: What are the properties that are essential to be defined in the entity passed to field_attach_update() for the function to update the appropriate fields (and not silently do nothing)?
This ...
2
votes
1answer
582 views
create a copy of a field-collection for entity clone
I have a use case where I need to create a copy of an entity (commerce product) that is home to various field collections.
the entity is created by a simple load/save combo:
// load entity
...
2
votes
1answer
145 views
Best way to set up data architecture
I have a system where (to start) I have three types of data I need to store. I'm familiar with relational databases so I'm going to describe it in those terms. The Author table just has a couple ...
3
votes
1answer
681 views
How to get users (entities) for a certain field value?
I want to write a function that returns users which have entered a certain value to a custom user field.
Lets say there is a custom birthday field for every user. What would be the best way to get ...
2
votes
0answers
24 views
Is there a property that is set by the field API once fields have been attached to an entity?
Is there a property that is set by the field API once fields have been attached to an entity?
For example
$entity->fields_attached = TRUE
I have been unable to find any information on this, I ...
5
votes
4answers
1k views
Excluding empty(Null) fields when using EntityFieldQuery query condition
Is it possible to select all of the entities who's xyz field is empty?
I tried soemthing like this:
->fieldCondition('field_name', 'value', NULL, 'IS NOT NULL');
However, this doesn't seem to ...
4
votes
3answers
1k views
Is there a way to load the current entity object?
Is there a way, from anywhere in drupal, to get the current entity object? I'm using the hook hook_filter_FILTER_process() and I'd like to replace things in the $text with data from the entity, but it ...
2
votes
1answer
1k views
How to attach a field to an entity programmatically?
Is it possible to attach a field to an entity programmatically?
I want to create a new entity, say vehicle, which has radio buttons defined for the brand of the vehicle. I would like this field to ...
2
votes
3answers
229 views
How can I make individual nodes fieldable?
One of the great things about the Entity and Field APIs is the ability to add fields to any entity (nodes, users, etc.) and subsequently any bundle (e.g. node content types).
But is there a way, ...