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
23 views

How do I store large volumes or data points using Drupal ( temperature and humidity points )

I'm trying to use Drupal as a headless API, and so far I'm having good results. One of the things I'm collecting is a Temperature and Humidity data. Thus far I've created an entity that can hold the ...
0
votes
0answers
42 views

Add a taxonomy type to a custom field using Field API

I maid an edit to make problem more clear. I'm creating a new field type using Field API (using hook_field_info , hook_field_schema ,hook_field_widget_info , ...) my custom field should store ...
0
votes
0answers
19 views

Use translated node title in views

I use the Title module together with internationalization in my Drupal setup. Everything works fine. I can translate the node titles and their translations are displayed fine on the node page when I ...
1
vote
2answers
16 views

Editting field collections with service api

I am trying to build an phonegap app which uses data of a drupal site. I need to update some informations with using app. For example I have nodes and users need to update field_collections of a node. ...
0
votes
2answers
35 views

How to add custom settings / attributes to a field

I want to be able to add custom settings / attirbutes to field instances. I can create a custom field with custom settings no probs, but is it possible to get rid of the custom field and just add the ...
1
vote
1answer
15 views

Using field api to get key of select list option

I need the safe output of a key from a select list field within a field collection item. I'm theming a field collection item and one of the fields is a select list like: icon-map|Map icon-info|Info ...
0
votes
1answer
21 views

Custom field widget form - Multiple values

I've create a custom field form widget for an entity reference field. When only one value is allowed it shows a (filtered) select list, but I want to allow user to assign multiple reference values to ...
0
votes
0answers
11 views

How can I escape the brackets so they are seen as literal characters

I am using clientside validation along with the field UI module in a Drupal 7 site to request some custom input fields on user registration. I need to set some custom error messages using the ...
0
votes
1answer
15 views

How to display translated options for list(text) fields with field_view_field()?

I have set up a list(text) field with translated content. In display admin interface (admin/structure/types/manage/***/display), I have set up it to "Default translated" in "format" column. Then if ...
0
votes
0answers
6 views

When is data field 'save_value' set and when not?

I am printing a node using the following code: $node = node_load(arg(1)); $output = field_view_field('node', $node, 'body'); dpm($output); And I saw that sometimes the data field ...
2
votes
1answer
88 views

Move required span of fields outside the label

Normally in Drupal if a field is required, the Asterisk sign would render inside the <label> tag in a <span>. for some reasons I'd like to move the span outside the <label> and ...
0
votes
0answers
22 views

Fatal Error while sending a multipart POST request to a image upload created using Field API

While testing a site i created using "Acunetix" web vulnerability scanner, it posted a multipart request to a image upload field created using Field API. The test manipulated a POST statement and ...
2
votes
1answer
90 views

Use a Custom Field in page.tpl.php

I have a custom field called site_category that I am using in a few different content types. The field site_category is an entity reference to a content type which has only one field defined: Title. ...
0
votes
4answers
179 views

Create a checkboxes-field with a radiobutton for all items

Usercase: Have a list with services for shops. Those services can be done with an appointment, or without. So the services are checkboxes, and the radio needs to show if it can be done with or without ...
1
vote
1answer
28 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
0answers
10 views

How do you populate a multi-value field with a specific number of empty fields?

How would you go about generating a specific number of empty fields inside of a multi-value field on page load? In my case this multi-value field is a simple text field, and I'll be passing a URL ...
0
votes
0answers
22 views

Switch Database in Entity Reference

The Drupal site is connected with two databases like this: $databases = array ( 'default' => array ( 'default' => array ( 'database' => 'default', 'username' => ...
0
votes
2answers
18 views

Flip Boolean Value in Field

I have a product with a field that's a boolean value "Contains Gluten" which stores a "1" for yes and a "0" for no, this is stored in the database as field_contains_gluten_value. The client now wants ...
0
votes
1answer
15 views

How can I make web scraping of a field more difficult?

I have a text field that I get with <?php print render ($content['field'][0]['#markup']); ?> in node.tpl. I'd like to somehow make loading the markup require a click, and deselecting it to put ...
0
votes
1answer
31 views

Access values from multiple field forms as elements of one form

I'm trying to create entities from my custom form. To do that, I created "Add more" button, where I'm dynamically adding new elements that I'm attaching fields to by using: ...
0
votes
1answer
23 views

On node edit form, how to edit field from a referenced entity?

I've got a master entity (node) that users edit, and I've got an entity reference on it. I'd like to be able to edit a field on the referenced entity on that master referencing entity's edit form. Is ...
0
votes
0answers
20 views

How to prevent user from deleting field but not from modifying it?

Just like in the question. I'm creating a module, and using field as it's essential property, I would like to allow people to change it, but make it unable to delete it by using Field API. Any ideas ...
0
votes
1answer
12 views

Drupal Field API - Settings List

I'm trying to create a 'link_field' in Drupal through a module, I've got the following code but I'd like to configure the field settings to do the following: Not require title Update the number of ...
0
votes
0answers
27 views

How to add text with summary field in drupal?

I am using drupal form API to create my form and want to create a text with summary field but when I use the type text_with_summary, nothing shows up in the form. For now, I have used two separate ...
0
votes
0answers
34 views

What is the use of module_invoke_all?

The documentation states the following. Invokes a hook in all enabled modules that implement it. All arguments are passed by value. Use drupal_alter() if you need to pass arguments by reference. ...
0
votes
3answers
46 views

Add foreign key to schema using hook_update_N

I've written a module that establishes a child/parent relation ship between magazine issues and the articles in each issue. The idea is that by associating articles with magazine issues they can all ...
1
vote
0answers
19 views

Massive conditionals in field_sql_storage_field_storage_load query

In Drupal 7, I've been struggling with a slow local (and remote dev) site for the past few days. If I try to edit a field on a Message entity type, it hits my 720 sec execution time limit (normally ...
1
vote
1answer
39 views

Wrong caching of embedded views block

I am having trouble with the Cache API in Drupal 8. I embedded a views block with pagination through a field preprocess function into a node. When caching is off, I can normally use the pager and will ...
1
vote
0answers
18 views

How to create a new widget for a plain text field

I have a text field on a content type in the admin. This week I only like people to fill in, say, the words 'yes','no' or 'i forgot'. I dont want to create a new fieldtype. Next week, I will implement ...
1
vote
1answer
25 views

how to make an existing listbox autocomplete

I have made a content type which has a list box field. now I need to change its widget to autocomplete but as you know list box fields does not have autocomplete widget. now I have added 650 contents ...
1
vote
1answer
17 views

translate a field before rendering

I made a content type programmatically with the entity_translation module. There are about 250 fields. 240 fields are not to translate because their values are identical. So I only want to use ...
0
votes
1answer
42 views

Field Template Suggestions: Target a particular field type on a content type

I want to use a field template for all the fields on my "journal_page" content type that use a widget of "long text". How would I do this? N.B. My field is not named "long text". "Long text" is ...
0
votes
1answer
22 views

Custom field “required” validation

I built a custom field type using the Field API. In hook_field_validate I have some logic to validate some very custom stuff, but when I tried to add a "This field is required" validation, I realized ...
0
votes
1answer
48 views

Hide Price by Role for a Content Type in Drupal 7

I am trying to achieve the following: 1> Hide Price Field for a Role only on a specific content type. I am using Drupal Commerce. Things I tried: 1> Field Permissions for the commerce_price field on ...
0
votes
0answers
18 views

Unable to get a new field type created using the code below

I am trying to create a custom 'field type' using the code given below But still when I check in the manage fields section and check for field type dropdown I can see the field type "Custom Animcan ...
3
votes
1answer
36 views

How do I initially show 3 blank fields on a form when cardinality is unlimited?

I have created a field programmatically that has 'cardinality' => FIELD_CARDINALITY_UNLIMITED. This is the functionality that I want. I want users to be able to add as many items as they need to. ...
0
votes
0answers
8 views

Why does this field_update_instance() call not preserve all settings?

I'm working with Commerce + Addressfield (and Commerce Addressbook). In a hook_update_N I want to configure sensible defaults for the site, but one of them (default_country) refuses to stick. Why is ...
0
votes
1answer
11 views

Additional field data stored outside of the field storage (in a separate table) doesn't load with the rest of the field

I've implemented a custom field that needs to store data outside of the Field Storage mechanism and in a custom DB table. (The field structure is enough to require a second table, but not enough to ...
1
vote
1answer
115 views

Saving values of a multistep form into custom entity fields

I'm building a module that implement a multistep form based on a custom entity. The entity contains fields which are created by the install file. I was able to create the steps and if I print the ...
1
vote
1answer
40 views

Enable field formatter settings

I have a field that I created using hook_field_extra_fields, and I want it to have a cogwheel like in the image below, so that I can customize it. Right now the only format setting for the field is ...
0
votes
1answer
34 views

how to alter a hook_field_insert

I am trying to find a way of altering the output of a hook_field_insert. In my exact example, I'm trying to hook into the link_field_insert hook, in the Link module: /** * Implements ...
0
votes
1answer
26 views

Check if entity reference field (user) contains current user

I have a node page of Project content type which contains a multiselect enitity reference field of user type called field_team. I also have a block created by my custom module which is displayed at ...
0
votes
1answer
121 views

Add custom text field to field settings form

In the admin when click edit on Manage Fields page it shows settings for that field. Can we add a custom property (checkbox) here like the required checkbox? For example, for a decimal field it show ...
1
vote
0answers
63 views

How do I programmatically copy an existing Field to another Entity?

I want to add two new fields to the Commerce Discount entity --- an image and a long text. And I want these to be visible through Views. I was going to use this code to add the fields: ...
0
votes
0answers
27 views

How to render views field without executing a view?

My task is to update field content via AJAX on node page and on view page both. On node page I can get rendered content of any field by calling field_view_field('node', $node, $field_name, ...
0
votes
1answer
43 views

how to get a field name by field label in Drupal 7

I have added a custom field with title 'play time'. How can I get the field name(internal value) using label value in my custom module. Is there any function to get the value?
1
vote
0answers
52 views

“Remove All” button for unlimited fields in Drupal 7

I've written a custom module for this functionality where my below code is able to delete the files but I think there should be a better way for doing that! <?php /** * Implements ...
0
votes
1answer
28 views

Allowed strings for the text field

I have the form which is created through Webform module and now I need to add one more text field but its value has to be unique and can be only the value from some predefined list of allowed values. ...
0
votes
0answers
18 views

add fields to a node mapped to date input.The fields value should be mapped to date value

I want to add fields to the a content type. The user should be able input text values that are mapped to a particular date. Ex: for july 1, a particular field can have a value of 145, for july 13 ...
0
votes
0answers
13 views

Read field value as string on login

In a custom module of mine (7.x), I succesfully call allocation_user_login(&$edit, $account) when the user logs in. The next step for me is to read the string value from the field field_group ...