All Questions
74 questions
0
votes
1
answer
54
views
Update the author_uid for an entity registration
I'm looking to update the author_uid for an Entity Registration in Drupal 7 programatically. I want to replace all anonymous users with the UID of 0 with another UID lets say 2 upon saving the ...
1
vote
0
answers
33
views
How do I create field collection of/in another field collection programmatically?
How can I create field collection in another field collection using Drupal 7 Entity?
The field structure is given below;
Content type: Properties
field_1
field_2
field_collection_1 (I can create ...
3
votes
2
answers
5k
views
How do I get $entity in hook_form_alter()?
hook_add_form() gets $entity_type and $entity as parameters, but hook_form_alter() does not have any of those parameters.
How do I get the entity type and the entity object in hook_form_alter()in ...
0
votes
1
answer
44
views
How to alter the $item value in taxonomy_field_is_empty without altering core taxonomy module?
How to alter the $items value found in hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) and pass it to hook_field_is_empty($item,$field)?
...
0
votes
0
answers
60
views
How to use theme_file_link?
I use the webform_multiple_file for my webform. I want to display webform submissions in a custom view.
I created my views-view-fields--submissions.tpl.php and added print $fields['value_1']->...
0
votes
1
answer
35
views
How to change the saving order of field_collection fields
I have a node with field1 and field2 (field_collection)
I am using hook_entity_presave($entity, $type) like this:
function txs_entity_presave($entity, $type)
{
if ($type == '...
0
votes
1
answer
47
views
Override field module function in custom module?
I want to override field_sql_storage_field_storage_write(), defined in /modules/field/modules/field_sql_storage/field_sql_storage.module.
I tried with MYMODULE_field_storage_write_alter($entity_type, ...
1
vote
0
answers
183
views
Custom Field API with multiple values - form generates two fields by default
I have a custom field that contains couple of fields (select, textarea, text). I've implemented hook_field_widget_form like so:
I've added a field to content type and set 'Number of values' to ...
2
votes
1
answer
172
views
Custom access callbacks for user entities not being called
I'm trying to implement some custom access control for user entities, in Drupal 7.
I've used hook_entity_info_alter to set
$entity_info['user']['access callback'] = 'MYMODULE_user_access_callback';
...
1
vote
1
answer
49
views
Where is the documentation for core associative arrays? [closed]
I have been using Drupal for a few months now at work. I love the developer documentation, but I have to say, I feel like its incomplete -- either that, or I just don't know where to find the other ...
0
votes
1
answer
328
views
Commerce Discount Module : Free Products : n+x
Is someone using commerce discount module and customized free products quantity field for buy x and get y functionality ? If i set buy 1 get 1(free product qty) its not multiplying while user updating ...
0
votes
1
answer
369
views
field widget is not saving selected value to database
I am creating a widget under taxonomy_term_reference field and trying to use the same autocomplete used by taxonomy module, autocomplete is working fine but data is not getting saved.
/**
* ...
0
votes
1
answer
172
views
Ajax not working inside hook_field_widget_form()
How to make ajax work inside hook_field_widget_form()
/**
* Implements hook_field_widget_form().
*/
function test_field_widget_form($form, &$form_state, $field, $instance, $...
0
votes
2
answers
269
views
How to avoid custom module hook_node_presave being overriden by a profile module node_presave
I'm willing to override a value before it get saved in database.
The same value is already overriden by commons_trusted_contacts module using hook_node_presave.
So my custom module hook_node_presave ...
0
votes
1
answer
23
views
How to set the Organic Group while saving a node based on the node's current language
We want to use a hook_node_presave to set the Organic Group (OG) field on the basic page content type based on the node's language. We have created several OGs using nodes and each one is assigned a ...
0
votes
0
answers
548
views
How to copy one field data to another and save a new revision?
We are going to remove an obsolete field(field_old) and will be using a new field (field_new) and have a need to copy the data from field_old to field_new (both text fields). Then we need to create a ...
0
votes
1
answer
31
views
How to create a module that shows some fields of profile2 type?
I want to create a module that shows some fields of profile2 type, in fact I want to show some information about any user in profile page of theme.
Profile2 type is "stores", field machine name is "...
1
vote
2
answers
926
views
How to delete all data in one field of a particular content type?
We have a content type basic page that has a Date field (field_bp_date). We want to use the hook_update to delete all data in this field. We are having trouble figuring out what is the best way to ...
5
votes
2
answers
3k
views
How to compare the already saved value of node and updated value?
I want to programmatically compare a field value of a node in hook_node_update(). How can I get the already saved and the updated values?
5
votes
3
answers
589
views
How can I programatically prevent users from saving the same entity twice in a row?
My server sometimes gets overloaded, and sometimes people press the "Save" button on an entity creation page several times, which results in multiple versions of the same entity being created.
So, I ...
1
vote
1
answer
345
views
How can I hook into entityforms being submitted?
I've installed entity forms. I have made a form. I would like to fire some code when a user fills out and submits the form I have created. I do not know how to do this. I don't know which hook to use, ...
4
votes
1
answer
1k
views
How can I hook into an entityform submission?
I've got entity forms installed, and I'd like to use some db_queries when a particular entity form is submitted, as to make use of the information filled out on that entity form.
Is this possible, ...
0
votes
1
answer
418
views
Override the body field with another field in hook_node_view
I have a node type that can be scheduled. Before the start time the page will redirect to another. This is all custom functionality and is currently working.
Now I need to create a coming soon page ...
1
vote
1
answer
666
views
hook_inline_entity_form_table_fields_alter add custom field
Need some help with Inline Entity Form hook function hook_inline_entity_form_table_fields_alter.
I'm trying to add columns to the table that is visible when editing a specific node. I have been able ...
0
votes
0
answers
32
views
It is possible to add some extra content to the rendable array of a node?
I have a hook_node_view_alter implementation in which a recive a node rendable array with its fields, data and stuff
It if possible to add like a fake field to it?
My goal is to print some data but ...
1
vote
1
answer
233
views
Conditionally change the image field style and wrapping it in a div
The Article content type has been classified by taxonomy vocab Topic, where each Article's node has one topic.
For some usability and design requirements, I want Articles belongs to a specific topic ...
0
votes
2
answers
2k
views
How to add metatag module data to the Search API indexes
I am in the process of building a new site that will have some content in the form of videos and PDFs. To make those more searchable I added the metatag module. We are also using the Search API to ...
0
votes
0
answers
120
views
How i can add folder in filedepot using a custom module (without rules)
I want to create a module that adds a FileDepot folder, in this module I want the user chooses a name for the folder and I want the Parent Folder will by default "Top Level Root", I began to create ...
1
vote
2
answers
1k
views
Add custom HTML to custom field
In a module, I have defined a custom field. Using hook_field_formatter_info() and hook_field_formatter_view(), I can manage the display of every item (value) within that field. I want to allow the use ...
0
votes
1
answer
509
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 ...
1
vote
1
answer
105
views
How i can use entity_metadata_wrapper for new database entry and update data in Drupal 7
How i can use entity_metadata_wrapper for database entry and update data in Drupal 7
I am using below code to save entry in database but not finding logic to update existing entry
$node = new ...
0
votes
1
answer
68
views
Running code only once when building a form
I have built a form using the field API. The function hook_field_widget_form gets called for every field. I have a bit of code that populates a select box but it is being called for every field in the ...
7
votes
2
answers
6k
views
How to create new field type
I'd like to create a new field type that can be attached to content (ie an article) via the admin interface through 'manage fields' of the content type. I am unsure of the process and required hooks ...
1
vote
1
answer
385
views
Calling hook_entity_view from a theme
Is there any way to call hook_entity_view() from a theme?
I tried adding the implementation to the template.php file, but the function is not called.
I know I can do it via custom module, but as it'...
1
vote
2
answers
1k
views
How to print a custom user field in comment.tpl.php?
I'm trying to print a custom user field (field_avatar) image as a replacement for the user picture. Why? user picture file directory would not accept tokens. This mean, I could run into a scenario ...
1
vote
0
answers
277
views
hook_node_presave() fired twice when adding new node
I've just noticed that hook_node_presave($node) is fired twice when adding new nodes: Once it's called from node_form_submit(); the second time from entity_save().
It turns out that $node->nid is ...
0
votes
1
answer
1k
views
Can't get hook_field_attach_view_alter to set the value of the field
I'm using some hook code I got from Drupal 7 show empty fields in order to show all of the empty fields on my node when viewing it. I would like to put a simple - as the displayed value when the field ...
1
vote
1
answer
588
views
problems with entity translation insert hook
I'm using the entity_translation_insert() hook to set the value of a field when a node is translated.
I can successfully edit the $entity from within the implementation, but how should I save the ...
2
votes
1
answer
251
views
Is there an hook to react to custom entity updates?
I need to react to updates of custom entities wich are using Entity API (Redhen organization in my case).
I tried using hook_entity_update($entity, $type) but it does not seem to be fired when ...
0
votes
1
answer
120
views
hook_field_schema not being used
I'm trying to create a field with an additional property (or column) to define an extra relationship to a taxonomy term.
I have this in my module file:
/**
* Implements hook_field_info().
*/
...
2
votes
3
answers
3k
views
How do I extract filename and filepath from a file field?
Here is what I am trying to tackle: I would like to allow a zip file to be uploaded via the default filefield upload widget for a content type. I am using hook_node_presave to take the zip file and ...
2
votes
1
answer
313
views
Module hook to add_js to any entity type?
I want a hook that will let me conditionally add js/css to the page depending on the type of entity.
Since I am putting this in a module I cannot use a theme hook (because if the theme already ...
4
votes
1
answer
2k
views
How to add template suggestions for entities?
I need to add a template suggestion for entities in a custom module, similar to how you can add one for nodes. I've seen the ones implemented in the Entity API module, but how do I hook into entity ...
1
vote
3
answers
3k
views
How to disable links in taxonomy term node fields [closed]
I have a list of rendered taxonomy terms in a node sidebar, rendered as h2 tags, linked to the taxonomy page for that tid. I don't want that term to link anywhere, so I want to remove the link and ...
0
votes
1
answer
109
views
How to change field value of a node
I have a field in a node where users entered data in an inconsistent format. I need to parse that data (it's HTML) and re-format it so it looks correct. Where is the best place to do this?
1
vote
1
answer
573
views
Hook for when a new content type is created?
Does a hook exist for when a new content type is created? If so what is it? I've looked through the API and nothing has jumped out at me.
2
votes
2
answers
430
views
Hook to import entity data in custom module installation in Drupal 7
What would be 'the best' hook function to use in the custom module installation to import entity data? This is supposed to be a one-time activity during the module installation only, after entity ...
1
vote
1
answer
239
views
Preprocess Field: CSS Style per page
Trying to set up a preprocess_field_hook() to send a different css style depending on the node that is loaded for simpler theming. Will not work and been beating my head.
Have this set inside my ...
0
votes
2
answers
3k
views
how to have conditional required fields through hook_form_alter?
Here is basically what I'm trying to do.
If the draft field is present I would like to make the name field not required.
if($form_state['values']['field_draft']['und'][0]['value']){
$form['...
1
vote
1
answer
5k
views
How to use hook_entity_presave?
I have a product type called package. It is a package of another product type which is called applications; when a user wants to create or update a package , I want to calculate the price of the ...