Questions tagged [form-api]

An API for add forms to your Drupal website.

The Drupal Form API allows for almost unlimited possibilities for custom theming, validation, and execution of forms. The idea of the API is to eliminate writing HTML for any form building and to make the flow of present-validate-execute as clean as possible. The API also allows for ways to manipulate multi-step forms by passing data from each stage of the multi-step process to the next seamlessly.

References

Form API Handbook

102 questions
12
votes
2 answers

Applying jQuery date picker to DCT in Teamsite

I am working on a HP autonomy interwoven Teamsite DCT and I am trying to add jQuery Datepicker to a "selectDate" text element. Basically this text element is a part of a replicant container with attribute min=1. So at the time of form load the first…
Sunil Kr. Yadav
  • 273
  • 3
  • 18
11
votes
2 answers

Drupal 7: Best Practice for a Dynamic Select List in Drupal 7

What is the best practice for a dynamic select list in Drupal 7? Create a Field with dummy options via the UI and overriding the options with hook_form_FORM_ID_alter or Creating a dynamic select list from scratch via a custom module with the…
sven
  • 111
  • 1
  • 1
  • 3
7
votes
2 answers

How can i do multiple file upload using Drupal 7 Form API?

I'd like to upload multiple files using Form API. '#type' => 'file' provides upload only one file. $form['picture_upload'] = array( '#type' => 'file', '#title' => t(''), '#size' => 50, '#description' => t(''), '#weight' => 5, …
Alexey
  • 6,552
  • 8
  • 54
  • 92
7
votes
1 answer

drupal form api checkboxes

I am using drupal form api and using checkboxes. I am getting problem in default checked values with it. following is the code snippet... $result = db_query("SELECT nid, filepath FROM {content_type_brand}, {files} WHERE…
Tausif Khan
  • 2,158
  • 8
  • 38
  • 51
6
votes
2 answers

How to disable a field or make it readonly in Drupal 7

I am trying to disable couple of fields and make them readonly via hook_page_alter(). I was able to do check if user is viewing the page edit section (the form edit) $page['content']['system_main']['#node_edit_form'] == TRUE) then when I tried to…
Mehr
  • 61
  • 1
  • 2
  • 3
5
votes
2 answers

Drupal Dynamic Select on a Form

I'm sure this is an easy one for jQuery experts, but I'm a backend guy, and can't find the best way to do this. I have two arrays in Drupal, one is a list of names of views, and the other is an array that contains a list of displays for each view. …
Justintime
  • 269
  • 2
  • 6
5
votes
3 answers

'add another item' in non-CCK Drupal forms

CCK for Drupal has the handy feature of allowing a single CCK field to accept multiple values via a "add another item" button that results in an array of data in the node. I'm wondering if there's any easy way of adapting this for a non-CCK form…
ceejayoz
  • 165,698
  • 38
  • 268
  • 341
4
votes
1 answer

drupal 7 file_save_upload returning false

I have a custom form, with a field for the user to upload an image file (their logo). In the form validate hook, I've implemented file_save_upload, which is continually returning false. I can see that the file is in fact being saved in the correct…
valen
  • 777
  • 1
  • 13
  • 38
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
2 answers

Why does this webform uploaded file via ajax throw an error in Drupal 7?

I have a webform and mymodule which alters it. The webform has a field stelle which gets populated based on the url query. For instance, if ?stelle=10 the field gets populated by the title of node with nid 10. If the query ?stelle is non-existant or…
Alex
  • 9,339
  • 2
  • 28
  • 46
3
votes
2 answers

Display uploaded image - Drupal 7 Form API

Here is my form field for users to upload their company logo: $form['company_logo'] = array( '#type' => 'managed_file', '#title' => t('Company Logo'), '#description' => t('Allowed extensions: gif png jpg jpeg'), '#upload_location' =>…
valen
  • 777
  • 1
  • 13
  • 38
3
votes
1 answer

How to put two form elements in a row using Drupal Form API?

I am creating a form in Drupal 6 using form API. I need to put a textfield and a select next to each other. they are for entering something like 'www.domainname.com' . www. is fixed. domainname section is given from user in a textfield and .com…
hd.
  • 15,498
  • 41
  • 106
  • 159
3
votes
1 answer

Drupal 7: Triggering an AJAX callback externally in the Form API

In a Nutshell: I'm trying to trigger an external event via jQuery, causing an AJAX callback on a Drupal form to be executed. This rebuilds several chained elements. It works once, but then breaks until the form is refreshed by a different element in…
Atomox
  • 522
  • 4
  • 15
3
votes
1 answer

Drupal 7 - Populate Drop Down select from DB in Form API

I am still new to PHP, and even newer to Drupal's Form API. I'm simply trying to populate a drop down select from the database. I think the issue stems from my lack of a deep understanding of how to work with multidimensional arrays. Any help is…
Lucas Healy
  • 135
  • 2
  • 10
2
votes
2 answers

Why isn't my drupal form submit function being called?

Ugh, this is probably something simple, but it is driving me crazy. I've got a simple form (just a submit button) that I am inserting into a node using hook_nodeapi(). It gets inserted correctly, and the page refreshes when I submit, but it is…
SenorPuerco
  • 839
  • 2
  • 8
  • 18
1
2 3 4 5 6 7