Questions tagged [drupal-fields]

Fields are custom data that can be attached to Drupal entities.

Fields are custom data that can be attached to Drupal entities.

Drupal 7 provides an API that takes care of storing, loading, editing, and rendering field data. Any entity type (node, user, etc.) can use the Field API to make itself "fieldable" and thus allow fields to be attached to it. Other modules can provide a user interface for managing custom fields via a web browser as well as a wide and flexible variety of data type, form element, and display format capabilities.
In Drupal 6, most of the field functionalities are provided by CCK.

Use for questions about the Drupal 7 field API, how to use it, and which hooks need to be implemented from modules defining new fields.

See also

83 questions
8
votes
4 answers

Drupal 8, get programmatically the list of fields of a custom content

I want create programmatically a custom content (custom content created via the admin UI). But, before the creation, I want check programmatically the types of fields of my custom content My custom content contains a field "body" (type text), a…
matthieu lopez
  • 1,558
  • 4
  • 24
  • 61
8
votes
3 answers

Drupal Views combine 2 columns into 1?

I've got two content types, both have a node title and a document attachment, the doc attachment fields are different names (being from two different content types). In my view, I'm displaying the node title and the file name in a table. The node…
Kirk Hings
  • 864
  • 3
  • 12
  • 26
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
  • 24,289
  • 12
  • 85
  • 99
5
votes
2 answers

Drupal 8 create field programmatically

I created a custom module for Drupal 8 that allow the users to choose a Content type in order 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
  • 76
  • 1
  • 4
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
  • 4,677
  • 3
  • 25
  • 36
4
votes
3 answers

Drupal 8, add an image field from a BuildForm with preview

I created a custom form from a buildForm function. In this form, I would like add an image field. I can do that via this code : $form['main']['image'] = array( '#type' => 'text_format', '#title' => t('image'), '#default_value' =>…
matthieu lopez
  • 1,558
  • 4
  • 24
  • 61
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,062
  • 1
  • 19
  • 33
4
votes
1 answer

How to Add Date Field type in Drupal 7

I was wondering how to add a date field type in drupal 7. I was following a video tutorial, when I notice that I dont have a "date" field type in my select options. How will i do that?
user2481398
4
votes
3 answers

Drupal 7 add headings to each grouped section in my content type?

I have created a content type and it has about 5 groups which are all vertical tabs. For some reason the Field group label doesn't work for vertical tabs. the

tag is always:

Vertical Tabs

. The title is always…
Cybercampbell
  • 2,358
  • 10
  • 44
  • 75
3
votes
2 answers

Display Label given key for select list

Given the following select list for the "field_priority" field, how can I display the label, given the key (e.g. 0, 1, 3)? 0|Low 1|Medium 2|High 3|Urgent
Chris Muench
  • 15,874
  • 66
  • 193
  • 332
3
votes
2 answers

Add custom fields to drupal navigation menu without breaking the version

Is it possible to add custom fields to drupal navigation menu (besides title and description)? I want to keep the version without breaking it.
fatnjazzy
  • 5,640
  • 11
  • 51
  • 79
3
votes
2 answers

Why can't I move a field into a fieldset in a Drupal form - fails to pick up current value

I have a node form in Drupal 7, in order to simplify it for the user I want to break it up into sections using the vertical tabs feature. Using hook_form_FORMID_alter() I can move the fields without difficulty. When the node is saved, it writes the…
3
votes
1 answer

hook_user(): inserting extra field into database not just form

I can add an extra field to the registration. What I need to know is what step do I need to take to then grab that input and insert it into the user table of drupal. The code below is in my module this adds just a field to the form, but when its…
Jonathan Tizard
  • 219
  • 1
  • 4
  • 15
2
votes
0 answers

Displaying custom fields in a forum

I have made some custom fields at config->account settings (manage fields) and I have put them in my registration form but I want some of them display at image I show below under the post count and generally when they create a new topic or…
dbexec
  • 264
  • 7
  • 18
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
  • 24,336
  • 15
  • 61
  • 93
1
2 3 4 5 6