Tagged Questions

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
22 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
17 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
11 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
14 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
19 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
18 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
3 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
26 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
7 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
17 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
24 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
1answer
33 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
71 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
19 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
16 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
0answers
21 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' => ...
0
votes
0answers
47 views

Creating a custom FieldType (D8)

I'm trying to create a custom FieldType which provides the fields for a complete address (street, house_number, post_code and city). I created a FieldWidget, FieldFormatter and FieldType class and a ...
0
votes
1answer
15 views

Custom Field type was empty in views

Im build a module, and this module was add a new field type, and all its good, but when i try to use this field in view, its print empty.. no value.., but when I use delta field, its retrieve value .. ...
2
votes
1answer
84 views

Field API - which hook to use? [duplicate]

I have successfully created a field with my module and managed to show it on user registration form. The next step would be validating my field. There are two hooks for this, and I'm confused as to ...
1
vote
1answer
21 views

Custom Drupal field widget causing check_plain() error

I'm working on a custom field widget for Drupal 7. Everything appears to be working correct, but now I'm getting this error: Warning: htmlspecialchars() expects parameter 1 to be string, array ...
2
votes
1answer
22 views

Modify how Drupal builds fields on a per form basis

I want to change the way Drupal builds specific fields on a specific node edit/add form on my site. For example, when I use print drupal_render($form['textarea']); in my ...
0
votes
1answer
37 views

multiple entity type in entity field query

how to add mutilple entity_type and bundles in EntityFieldQuery? $query->entityCondition('entity_type', 'profile2') ->entityCondition('bundle', 'user_profile'); Is there any way to do ...
0
votes
2answers
52 views

Custom field widget: hook_field_is_empty()

I'm creating a custom module that has implemented these hooks: <?php /** * Implements hook_field_widget_info(). */ function MYMODULE_field_hook_info() { return array( 'CUSTOM_field' => ...
1
vote
1answer
32 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
33 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
27 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 ...
1
vote
2answers
128 views

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
42 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
22 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
45 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
28 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
37 views

Setting up a multi-value field with a fixed value (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 next to first field. This button should disappear if number of items is equal to 3.
0
votes
1answer
56 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
16 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
26 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
108 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
21 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
163 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
59 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
52 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
18 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
13 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
21 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
76 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
27 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
57 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
242 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
13 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
35 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
50 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 ...