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
1answer
25 views

Create themable field group

I have a custom entity with several fields. Now I would like to group the fields and give each group it's own twig template so that I would be able to compose a page (my custom entity) containing ...
0
votes
0answers
16 views

Own Field Type is not saving the value [on hold]

I'm trying to write a own field type, so far so good, but the value isn't saved. Only NULL is written into the db. I'm probably doing something wrong, but I can't figure out what. I've started with ...
0
votes
3answers
38 views

How to problematically display an image field in Drupal 7 + default value when needed

I've used field_view_field to display an image field for a specific entity in Drupal. The problem is when that entity doesn't have any value for field. I expect field_view_field to display the default ...
0
votes
0answers
30 views
+50

Re use link field (of link module) in custom module to save custom data with it

Here goes background of my issue & question related to it: I am calling link_field_info() & changing some properties of field to use it with custom name. Code - function custom_field_info() ...
0
votes
1answer
15 views

Delete field and related data (field_delete_field, field_delete_instance)

I want to delete field from my Content Type using hook_update and wondering how to do it in most correct way. I know that my field is only on 1 Content Type (page). Here is my current solution. ...
0
votes
0answers
14 views

How to check the selected hour(eg:9am, 10am, 11 am,12pm in dropdown list) is between a range of hours using views exposed form

How to check the user input hour(eg:9am, 10am, 11 am,12pm in dropdown list) is between a range of hours(eg: office hours 9am - 6 am) in views exposed form. I am using BEF settings and installed the ...
0
votes
0answers
12 views

Field API and the database saving value from dynamic select

I have a custom module with custom field. I have two values to store in the database. The first one is a simple text field and it's working great. The second one is more complex. It's a radio ...
0
votes
0answers
21 views

How to build render array for image with custom link without using field_view_value()

In a custom module i implemented code to display a image which links to a custom destination. I got it working by building a render array with field_view_value(): Code snippet I: $link = ...
0
votes
0answers
7 views

How to integrate hook_field_extra_fields with hook_field_formatter_info (if possible)

I would like to know if it's possible to integrate a custom field defined with hook_field_extra_fields with a custom field formatter to be able to configure it by the UI custom settings on the ...
0
votes
0answers
8 views

My module's custom fields are not picked up by entity_metadata_wrapper and thus Rules

The problem I have is that I am using a module called Trackfield that defined a CCK field for D6, I (inexpertly) ported the module to D7 to use the Field API. My port works great and I have been using ...
1
vote
1answer
26 views

Replacing a certain character pattern in a textfield when saving an entity

I got an entity type containing a long text field. If a user types in a certain character pattern ("xX" for example), this string "xX" should replaced with "×" (the proper symbol for multiplication) ...
3
votes
1answer
31 views

Image field - 'Number of values' is not showing up in admin form

Something's very wierd with my existing Drupal 7 setup (current Drupal version, set up in early 2013, custom Zen Subtheme). When I create a new Content Type with a new Field Type "Image" this 'Number ...
0
votes
0answers
27 views

How to create a multifield programmatically without using features

I have a custom module that I am working on that uses a couple of custom content types. I am trying to keep the module as self-contained as possible and thus far I've been able to create my content ...
0
votes
1answer
21 views

Use Plugin Field inside buildForm()

In Drupal 8, I use this code inside my buildForm() method: $form['medias']['file'] = array( '#title' => t('Image'), '#type' => 'managed_file', '#upload_location' => ...
5
votes
2answers
141 views

Where should I be storing custom node-related data?

There are several types of data my website generates for every node. Node's popularity score, node's comment count obtained from a 3rd party API, etc... This data is set for every node. In the past ...
0
votes
0answers
14 views

How to find elements inside a commerce order form with dpm()? [duplicate]

I want to identify a specific field inside a commerce order form. The machine name of the field inside the order form is: commerce_customer_profile. Using Devel Themer I've got: ...
1
vote
1answer
14 views

When hook_field_info_alter is invoked?

I am trying drush cc all, but no luck. https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_info_alter/7 I need to programmatically hide a field and thinks that this is ...
0
votes
2answers
45 views

Make form to show multiple field widgets with predefined values

I have a node form with multivalue field (cardinality unlimited). I need to show user 3 widgets if this field with predefined value (like shown at screenshot). At screenshots I show the current form, ...
0
votes
0answers
55 views

Prepopulate field collection programmatically

I have a content type with field collection field (unlimited cardinality). Each collection has image field (required) and long text field. How can I prepopulate node form with multiple collections? I ...
0
votes
3answers
60 views

create a taxonomy and attach a field to it programatically

how can i attach a field to an entity (vocabulary) programatically in drupal 8 I created a vocabulary $vocab = entity_create('taxonomy_vocabulary', array( 'name' => 'vocab_name', ...
0
votes
1answer
19 views

How to create a custom field with a custom FAPI element?

I am writing a custom field module for phone numbers. The field has 4 different parts: A select element to choose the type of phone number, (phone, fax, toll free, other), A text field for the ...
1
vote
1answer
42 views

Do I need a custom content type, entity, module or field?

I'm working on a product information manager, and I have a content type of product which needs to reference stock and price levels for each supplier from a different database - these are stored as ...
0
votes
0answers
17 views

How to create a field in tests in Drupal 8

I am writing a test in drupal 8, in this test(simpletest) i create a content type(using drupalCreateContentType). I need in this content type create some fields. Now i need a taxonomy field, but will ...
0
votes
0answers
13 views

Setting database keys / index on fields

How do I specify that a field should have an index? I can only see references to indexes in the search api, but that seems to be something completely different. How would I also create compound ...
0
votes
2answers
49 views

Removing required attribute on user entity fields not working

I have added fields to user entity and make them required and show on registration page. So the user signing up have to fill all the fields. On the admin side these all fields are coming but i don't ...
0
votes
1answer
39 views

Changing value of min / max resolution for an image field dynamically based on a previous select list

Does anyone know if there is a way in Drupal 7 to change dynamically the value of minimum / maximum resolution for an image base on a previous select list. Example : I have a select with 3 elements ...
0
votes
1answer
25 views

Adding new fields using hook_field_schema_alter()

I have an entity whose field schema is already defined and now I am trying to add couple of fields to it. But I am not sure how to code it up using schema_alter.Below is an example on how I would ...
0
votes
2answers
49 views

Get field widget settings

In Drupal 7 they can be found in object that is returned by field_info_instance(). Is there a way to get widget settings for certain field name and bundle in Drupal 8?
-1
votes
1answer
41 views
0
votes
1answer
14 views

Attaching Conditional widget on Drupal Field

I have extended drupal user registration form by attaching fields to user entity. One of the field is to let user select duration. I have set it up as radio button. Form: When you started: (radio ...
0
votes
1answer
45 views

Using entity form display modes

I have created a custom form display mode my_mode for nodes and wish to display node form using this mode instead of default one at a custom page. How can I do it? ...
0
votes
1answer
21 views

display just the label from node_lode()

How to display just the label from the object returned by the function node_load(). the field_view_field() can hide the label and view the value but i want the converse.
0
votes
2answers
65 views

Validation and Setting value for Multi-value fields

Consider for a content type, there is a text field with multiple values capability activated. How can I check its values by $form_state inside the Validate/Submit function? How can I set its values ...
1
vote
1answer
54 views

Alter field (multiple values) to add more items/values of another field

In my case, I use Drupal Commerce (Kickstart 2x distribution) with a images field (multiples/unlimited values). I need to display all images of parent product AND images of their childrens ...
0
votes
0answers
50 views

Creating a Custom Editable Views Field

I am trying to create fields that can be used by the Editable Views Module which are from my own schema. I have not yet be successful in creating a complete implementation of the FieldAPI which has ...
-3
votes
1answer
22 views

Field value of a content type is not saved

I have a content type (created through a feature) which has different fields. One field is a text field. It used to save data before but now it doesn't save any value. I checked in the table, the ...
0
votes
0answers
15 views

How to change integer field suffix base on value of other field

I have a content type property which has price as integer field and contract type as radio with options "Rent and Sale". I would like to change the price suffix depending on contract type option ...
0
votes
0answers
26 views

Looking how to update field before node saves

I am looking to update a field with another field before saving or when the node is updated. I want to update a field array's (field_location_test) longitude and latitude values to a field that has ...
0
votes
1answer
81 views

Drop-down select instead of selection box in custom field widget

I am creating a custom field for phone numbers. The field creates a phone record that contains the type of phone contact (work, home, etc), as well as the number and an extension... much like Apple's ...
0
votes
0answers
24 views

Adding a custom logo to the title in a Drupal 7 RSS feed

I'd like to add a custom logo after the title in my rss feed. Normally if there were an rss.xml I would add the after the tag, but in the admin panel for rss there doesn't seen to be a way to add a ...
0
votes
0answers
33 views

Add Another Item on Multivalued Field Fails on Custom Form

I have a custom module building a form with fields attached from various nodes using field_attach_form(). However, when I click "Add another item" on a field with unlimited values, a POST request is ...
0
votes
1answer
38 views

How to modify field_suffix after form submit?

I have a form with a custom suffix (#field_suffix) for a field. I need to change the suffix value after the form has been submitted. Which hook should I use to achieve this ? Sample Code : ...
0
votes
0answers
9 views

Display custom field setting

I have altered a field using the following code, It basically adds a setting to the list field type called tooltip_text so that I can render the contents of this field in the widget. function ...
0
votes
1answer
19 views

Get term value from user field and set that value to new field

How to get term from user field and set that to the field in node? When user is creating node I need to get term and set it to the node field. I have field_term_reference in user fields and in node I ...
1
vote
1answer
33 views

How to know the “name” of an input field of a commerce checkout form?

I need to find the name of an input field of a commerce checkout form to use in: form_set_error('NAME-HERE', t('Field cannot be left blank')); The html of the field is: <div ...
1
vote
3answers
71 views

Drupal 8 field API vs. $form_state

I am creating a field with Field API, and having it shown on user registration form. However, I need its value in order to make validation. For that purpose, I've used dpm($form_state) which gave me ...
0
votes
1answer
113 views

Required field set via hook_form_alter not fully working in Commerce Checkout form

I created a hook function to make a field required and visible. The targeted form is the Checkout Billing Form at: example.com/en/checkout/35 I have to mention that the site is build with the ...
0
votes
1answer
35 views

Add a user/author field formatter

i have a site where I use display suite for custom page display. And all works. Now I need to add a custom field formatter for the "Author" field, but I don't find how to link "author" to a new field ...
0
votes
1answer
33 views

Converting existing autocomplete field to custom Drupal field

I have an existing autocomplete field outside of Drupal that uses jQuery UI's autocomplete functionality and makes a call to a custom PHP script to parse the input and return formatted data as JSONP. ...
0
votes
1answer
96 views

Multiple Field , same ajax callback

I created a custom field. The hook_field_widget_form has an submit element with an ajax callback: //Add more $element['add_zone'] = array( '#type' => 'submit', '#name' => ...