Questions tagged [drupal-field-api]

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 "drupal-fields" for questions about fields implemented in modules you are using.

The field API implements only the part for creating fields that was part of the CCK module; it implements also the basic fields, but it doesn't implement all the fields that were part of CCK in Drupal 6.
The CCK module is still necessary for updating from Drupal 6 to Drupal 7, in a site that previously used CCK, and to use all the fields available in Drupal 6.

30 questions
6
votes
3 answers

Drupal 8 create field programmatically

I created a custom module for Drupal 8 that allows the users to choose a Content type in order to add some fields programmatically. How I can create some fields (text type in this case) and attach they to a Content type with a custom module? Some…
Alex Pezzini
  • 86
  • 1
  • 1
  • 4
6
votes
1 answer

Creating Custom Field Formatter is not working

I'm trying to create a new custom field formatter for text fields but nothing is showing at all. I tried un-installing and re-installing the module and flushed the cache many times, and nothing worked. Here's the code I used /** * Implementation of…
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
5
votes
1 answer

How do I set a field value with the field API?

I'm using the Drupal 7 field API, which seems great: I can add a custom field for the 'user' entity type, and edit in the GUI. I use field_get_items($entity_type, $entity, $field) to get the custom field values. I now need to programmatically set…
Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
4
votes
3 answers

Custom Drupal 7 Field only saves the first character

I'm essentially trying to create my first field type module using the new Drupal 7 Field API. I've managed to get it to display correctly in the "edit" view. However, when I try to save some data it only saves the first character. Here's the…
Teo Klestrup Röijezon
  • 5,097
  • 3
  • 29
  • 37
4
votes
1 answer

Drupal-7 how to get hook_field_[formatter_]prepare_view() invoked without overwriting existing formatter

From my module, I'm looking for a way to change text-fields value during rendering process, but WITHOUT creating a new formatter, and BEFORE the currently affected formatter works. In other words I want my changes always made on any text-field, as a…
cFreed
  • 4,404
  • 1
  • 23
  • 33
3
votes
2 answers

Pull field values of Drupal Views Custom Field $data variable?

In Drupal 6, I'm using the Views Custom Field module to insert some php into my View. The helper text in the php CustomField reads: $data: contains the retrieved record from the database (e.g. $data->nid). Okay... seems pretty straightforward. So,…
Sam
  • 2,152
  • 6
  • 31
  • 44
2
votes
2 answers

Custom field in Drupal 7 with multiple file fields

I'm making a custom "video" field that is supposed to accept several files (for different video formats) and a caption. So far the schema is fine, but I can't get it to upload and store the actual files. My code in hook_field_widget_form looks like…
cambraca
  • 27,014
  • 16
  • 68
  • 99
2
votes
0 answers

Fetching translated allowed_values of non-translatable list_string field

I'm attempting to get the allowed_values of a non-translatable list_string field. The allowed_values of this field are translated though and we want to get those allowed_values into a specific language & not the current UI one. Here is my draft…
Kevin Wenger
  • 1,484
  • 1
  • 13
  • 29
2
votes
1 answer

Adding new custom field to existing content type

I' m using a module in creating certain pages, but i want to add an extra field to each page where the admin can modify I ' m kinda lost , not sure how to do it Thanks
airnet
  • 2,565
  • 5
  • 31
  • 35
1
vote
1 answer

List of fields for a content type in Drupal 7

What im trying to do is get a list of all main fields content type has created (core fields and cck fields). Similar to what is described here: How to list CCK fields by content type in Drupal but for Drupal 7. Help anyone?
AlekzZz
  • 11
  • 1
1
vote
1 answer

Making an existing content type a field in another content type in Drupal 7

I'm still working my way up the learning curve for Drupal and I can't seem to find an answer. I have created a custom content type. In my case, it describes an investment property (purchase price, rental income, etc). I now want to create another…
Ryan Price
  • 315
  • 6
  • 17
1
vote
1 answer

Drupal: - Field Info API as REST

We would like to get label for the field. As per previous question: How do I get a field label by the field name? But I need to get this through the REST API of Drupal. Could anyone please suggest what should be the approach to use the Field API…
Banng
  • 531
  • 1
  • 6
  • 19
1
vote
1 answer

Undefined index: custom field in locale_field_entity_form_submit() (line 438 of locale module)

Hi I am getting this kind of error in creating custom node type with custom fields: Undefined index: field_block_pre_login_body in locale_field_entity_form_submit() (line 438 of D:\xampp\htdocs\projects\foo\modules\locale\locale.module). Custom…
Cedric
  • 1,236
  • 2
  • 18
  • 35
1
vote
1 answer

printing all the "articles" related to the content type

my content type, plan to have one or more 'articles'. the following php code, I can get them all: and I get the following result: I would like to remove the title in bold above the…
Antilope
  • 443
  • 2
  • 6
  • 17
1
vote
2 answers

Displaying content of term reference instead of link (Drupal 7)

I need help with this Drupal 7 situation: I'm publishing travel agency offers using my own content type named "offer" I'm storing information about hotels (descriptions, prices, photos, etc.) in taxonomy named "hotel" I need to display relevant…
1
2