Use this tag for questions about the field API, how to use it, or which hooks are required to implement a field in a module; use "tag:fields" for questions about fields implemented in modules you are using.

learn more… | top users | synonyms

1
vote
1answer
27 views

Why isn't my programmaticlly created field showing up to be added to a content type

I'm trying to create a field that I can add to content types via my module, here is how I'm doing it: /* Create the field to hold RSVP info */ function kade_rsvp_enable(){ ...
1
vote
1answer
7 views

Custom Field Type hook_field_widget_form() not showing #title values

I have created a custom field type. When creating a piece of content with this field type I get a select list and a text area like the image below. However, I have stated that the '#title' for the ...
0
votes
1answer
10 views

Custom field widget that displays a button with JS action and a hidden textbox

I have no background in working with the Drupal API, so answers will have to explain it like I'm a child. I am trying to create a custom field module. The widget should show a button with JS onClick ...
0
votes
2answers
77 views
+50

Save multi value in multi value field programmatically

apologize every one , my code was correct , I had a mistake in content type .2 similar content type with 2 similar image field :P but I let it and don't delete this because maybe be useful in futures ...
0
votes
1answer
25 views

how to get the response in JSON format?

I am using Drupal 7 Services to expose an API, The following is the code I am using to get some of the datails and It is giving the response interms of Arrays, But I don't want the response to be in ...
0
votes
0answers
18 views

prevent ignore empty field in multi value fields

let suppose I want to create a cast table, in one field with multi value write down actors and in another write down their roles, as example A has "role A" B has "role B" C (no role) D ...
0
votes
1answer
22 views

How can I attach a line item field to a custom checkout pane?

How can I attach a line item field (as form element) to a custom checkout pane ? I tried the following with commerce_line_item_save($line_item); function MODULE_pane_checkout_form($form, ...
0
votes
1answer
26 views

Is it wrong to programatically create an entity without its required fields?

This is a general question, but based on a specific situation. In Commerce the standard way of customising a product AFAIK is to use Commerce Customizable Products. It allows you to create different ...
2
votes
0answers
19 views

Setting up a multi-value field with a fixed amount of values (not unlimited) but with add another items button [closed]

I want to set the number of values for a field to 3 but with add another item button after the first field. This button should disappear if number of items is equal to 3.
0
votes
1answer
34 views

Creating a Custom Field Type for Fieldable Entities

Problem My custom field type will not save data. Every time I save the entity it is attached to (it doesn't matter what entity I do this on) the value always comes out NULL and SQL throws an error ...
0
votes
1answer
15 views

Writing a field formatter for D6

So I'm almost embarrassed to ask this, but it's been so long since I've touched Drupal 6. We've been asked for something which requires another Field Formatter for a File field. Form the code below, ...
0
votes
1answer
18 views

Custom field not saving updates

I've created a widget which has two textfields and a hidden uniqid. One of these fields is for the name of an item, the other is the number of people who can be involved in that item. These save ...
1
vote
2answers
27 views

Turn off revisions for content types that contain certain types of fields (e.g. Field Collection)

The Field Collection module does not support revisions. Yes there are lots of patches which are still under review. But what I want to do is create a module that on the node edit screen, queries the ...
0
votes
0answers
18 views

Custom field API translation issues

D7 site: Locale and Entity translation modules are enabled.. using translatable fields. I have a custom field created in a module, for holding product specs. When admin enters specs in one language, ...
0
votes
1answer
52 views

Get taxonomy term field value?

I have some taxonomy terms that have an image field in them. I am trying to get the value of the image field in my templates. How can I do this? The field's name is field_header_image. I have this so ...
0
votes
1answer
45 views

Programmatically add PDF file to user

So using the 'file' module i have added a field to the user table called 'user_files'. What i want to know if how can i programmatically add a file to the user, so that it is displayed on the users ...
0
votes
3answers
42 views

Remove classes from field display

When fields are rendered they have classes. For example here is the template for a taxonomy term reference field: <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ...
0
votes
1answer
16 views

compare terms from userterm and node term

I have users and nodes. bith have the same term referende field: field_area goal is to display a message in node.tpl.php when: - user has term 'south' - node has term 'south' i have used the field ...
0
votes
0answers
10 views

Using taxonomy field to build custom image field formatter

I want my file-entity 'image' to be displayed with a custom formatter applying conditional markup: when a taxonomy-term-field, which is attached to my file-entity, contains terms, then the link should ...
0
votes
1answer
18 views

field widget with multiple input fields

I need to create a custom field widget that is actually a 2 input fields group. I also need to save these values (I guess this is done through hook_field_schema()) The main problem is that I'm a ...
0
votes
0answers
48 views

Multiple Select with Array of Values - Field Type API

I'm creating a custom field type that is a multi-select with the ability to add new options to it via AJAX. I've created the multi-select and successfully have it storing values in the database as a ...
0
votes
1answer
26 views

How can I use View modes for entity without bundles?

I have an entity that has no bundles(ie. it has itself as a - 1 - bundle) and I need to be able to use View modes for it. My understnading is that the Field UI needs the 'bundle of' entity to exist ...
0
votes
1answer
42 views

Limit/nullify entity reference query/loading of select options, if using hook form alter to populate with ajax

I have added an entity reference field to a profile2 profile entity. The entity type referenced by this field will contain thousands of results (university courses). I have used hook_form_alter to add ...
4
votes
2answers
198 views

Rendering arbitrary field values without a parent entity in Drupal 8

I would like to expose to the user their choice of field formatters and the respective field formatter options. The selected formatter would then render an arbitrary array of items in the same format ...
1
vote
1answer
11 views

Pager on Widget Form Query

The module is a small custom widget for the entity reference field. It creates a list of nodes that allows for multiple selections. Is it possible to paginate the results of the query even though ...
0
votes
0answers
23 views

Custom widget taxonomy illegal value

When it goes trough taxonomy_field_validate on submit i get the error: illegal value. When i check th $items wich get passed to the function i see tath they got the wrong format: $item = array( 0 => ...
0
votes
0answers
28 views

Custom ajax field validates title

I have been trying to create a custom field which uses ajax to pull in values into it. The field is made up of a url and a content field, the ajax button uses the url field to fetch some content and ...
0
votes
0answers
29 views

how can I hide field collection item

I know I can hide form field element by $form['element']['#attributes']['style'][] = 'display:none;'; or hide($form['element']); but when I try to hide field collection element by ...
0
votes
0answers
12 views

Add additional values to a field using Form API?

I'm using the Form API to build out an admin form. One of the things I need to do is to be able to add additional values to a particular field (in my case unlimited values), similarly to how you'd ...
0
votes
0answers
69 views

Add custom fields to image field

I have a case where I need to add three custom fields to each image in an image field to hold data. The content of these fields will not be displayed, but will only be indexed into Solr so they can ...
0
votes
0answers
42 views

Webform: Time Field - Changing Variable Increments

I've been looking into a way to alter the intervals for the minutes in my time field on my webform in Drupal 7. Making the minute dropdown list to be in 15m or 30m instead of 1m. How would I access ...
2
votes
1answer
21 views

User List of user roles in List field af a content type

I would like to add a new field type in my content type. The field is of the type List(Text) and the possible values should be the list of user roles in the system. Is there a way to do it without ...
1
vote
1answer
31 views

What is the order of return value for field_info_instances?

I've used field_info_instances function to retrieve all fields info under a content type. field_info_instances('$entity_type','$bundle_name'). As from API page, If $entity_type is not set, return ...
0
votes
1answer
30 views

Why does field_get_items() sometimes return “blank”

field_get_items('node', $my_node_object, 'field_[fieldname]') is returning the string 'blank'. Not an array, not NULL, but a string reading 'blank'. It's causing errors in media_wysiwyg module. What ...
0
votes
0answers
63 views

Field collection - child fields adding class and weight

I've recently installed the Field collection module on Drupal 7. I have a field collection filled with 3 fields: field_text_section field_image_position field_image_section field_image_position ...
1
vote
0answers
33 views

How do I add custom validation constraints to Entity fields? [duplicate]

I'm trying to add validation (i.e. constraints) to a field added to a specific (node) entity. As per documentation here https://drupal.org/node/2015613 i'm trying to change the Field Definition to ...
0
votes
1answer
54 views

Add field formatter settings to all field formats

I would like to be able to modify the display of any field formatter. To to this I think the best approach is to add settings to all field display formats. Alternatively, I could create my own field ...
0
votes
0answers
20 views

Incorrect array depth when saving custom field

I have a module that implements all necessary hooks for a custom field api. I can see hook_field_validate() and hook_field_is_empty() working properly and values are also available on hook_pre_save() ...
0
votes
0answers
54 views

field_attach_form: multi-image is not working on ajax

I am using custom form and in a fieldset I am assigning field which is from content type I get by using field_attach form. When I attach it directly it is working fine. But when I use it attaching to ...
1
vote
0answers
16 views

How to use a field as an entity's property

My module provides its own entity. I need my entity to have a link field with multiple values. The module link is suitable for this. At install hook, I create a field and a field instance of link ...
2
votes
0answers
29 views

Dealing with #disabled and #access in hook_field_validate

is there any way to disable hook_field_validate when the corresponding field widget is disabled (via #disabled = true or #access = false) in corresponding form? Or, alternatively, is there at least ...
1
vote
1answer
30 views

Unable to retrieve user id of edited user from $entity in hook_field_validate

I have this little problem with a custom field that is bundled with user. In its validation function I need to have access to the user id of the user whose field is being edited. What that means is, ...
0
votes
1answer
45 views

How to convert a unix timestamp field in views

I'm keeping a Unix timestamp in a text field. In Views, I want to convert it to a readable date. This is a commerce view, and the field is a custom field of an order. Can I use ...
0
votes
1answer
25 views

Is there any API to get corresponding field in a custom content type?

I have drupal 7 and created a custom "content type" with several fields. just imagine i have: title field subtitle field I need to search the data. I want to search titles and when i found my ...
0
votes
1answer
100 views

How should i get corresponding field value for taxonomy filed attached?

I use drupal 7. I created a content type with these fields: one field to upload a file to private folder a taxonomy field (for that file) my problem: i can save one file with one taxonomy! but ...
0
votes
0answers
6 views

Add new field/field instances to my custom entity when installing module? [duplicate]

I have created a module that creates/declare a new entity type/bundle. I want to create a new field(Field API) and field instance to attach to the bundle but I don't know where to put my code? I ...
0
votes
0answers
55 views

How To get custom entity field show up in rules actions - drupal 7

I am using drupal 7. I have a textfield from a custom module (birthday module) on a user account entity which i named "field_birthday" but when i try to create a rule that will apply on the field, it ...
0
votes
1answer
89 views

How to display all values of List (text) instead of just the selected ones?

When viewing a node, how can I display all values of a List (text) instead of just the selected ones. So, instead of displaying: B (good) I want to display all values, with some markup telling ...
0
votes
0answers
53 views

Dynamic list of select field

I have created list field for content type. My allowed values list is huge and dynamic. Is there any way i can use this field and dynamically create allowed values list, without saving all options in ...
0
votes
0answers
19 views

How to change the order of the fields returns by field_info_instances() function? [duplicate]

I am using field_info_instances() function to get all the fields of a content type and display it in a csv file. but the problem is I can't change the order of the fields return by this function. ...