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

0
votes
0answers
6 views

Choosing an image field's format or width/height using template_preprocess_field

I'm using this function to get a custom user field in node.tpl: function MYTHEME_preprocess_node(&$vars) { $node = $vars['node']; $user = user_load($node->uid); $logo_var = ...
0
votes
1answer
10 views

Getting the field of a user based on uid or name

I'm trying to display some custom user fields of an author, of a content type's nodes. The only fields in $node that relate to the author seem to be $node->name and $node->uid. I tried this in ...
-1
votes
0answers
19 views

How to arrange fields in grid structure programmatically in drupal?

I am using field_view_value to render fields in template.tpl.php. In between I want the fields to be arranged in a grid before they're rendered in the template. How do I do this?
0
votes
0answers
17 views

How to store fields of a particular content type in database using serialize()? [closed]

I have a content type list. For each Content type, I have it's own fields. I stored selected content type value in database. Now I want to store it's fields also in database. This is giving me ...
0
votes
0answers
9 views

Undefined index: comment_node_quiz in Field List report after uninstalling Quiz module

After uninstalling Quiz module, my Field List report displays about 40 red notices about undefined index. They look similar to this: Notice: Undefined index: comment_node_quiz in ...
0
votes
1answer
36 views

how to modify field of a node?

I have a custom text field which I use to display some voucher code to users. I have it in a custom content type named (machine name) : 'add_deal'. What I want to do is to style the field when the ...
1
vote
1answer
38 views

Controlling node's content using field setting

In a module I am developing I wish to control display of a link in node's content depending on user's choice. I want to display this option to user(whether he wants to display the link on particular ...
0
votes
0answers
16 views

How do I substitute a field file input type in node create/edit?

I have a field image called "getFromFlickr". Via hook_field_widget_info(), I create a piece of form that (when in edit/create node), build a modal, call flickR, get one image, save the file in the ...
0
votes
0answers
14 views

Programmatically set a multi value date field

$checked = array(); foreach($form['field_rundays'][LANGUAGE_NONE]['#default_value'] as $key => $val) { $checked[$key] = $val; } r($i=0;$i<count($checked);$i++){ $date = ...
1
vote
0answers
24 views

How to remove a configuration object from active config in Drupal 8

I'm writing a custom module for Drupal 8. It defines a field storage config object, in a file called modules/mymod/config/install/field.storage.bloom_stem.bs_twitter_ac.yml. The problem is that this ...
0
votes
1answer
22 views

Drupal node_load display all fields

I have a template for a view in which I load a node. Is there a way to get the value of all fields from that node? Like, if I add another field in CCK it will appear automatically in the template. ...
2
votes
1answer
35 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 ...
1
vote
0answers
99 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
22 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
18 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
38 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
24 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
36 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
12 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
18 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
94 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
112 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
191 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
31 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
12 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
26 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
34 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
29 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
14 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
33 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
37 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
53 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
24 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
40 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
29 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
44 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
24 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
58 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
39 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
10 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
12 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
140 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 ...