Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [forms]

Don't use it for entity or entity field forms.

9
votes
1answer
14k views

Changing the registration form

I would like to revise the default new user registration form in Drupal 7. Rather than to requst "username", I want to request "full name" with helper instructions to enter the text "username is your ...
2
votes
1answer
290 views

Form won't submit properly on the front page

I have placed a form on the front page of my Drupal 6 site using drupal_get_form('mymodule_form'). I have not done anything different than usual, and I have implemented a validation handler called ...
2
votes
1answer
154 views

I am not able to traverse from the last step to the first step in a multistep form

I have created a multistep form with five steps using programatically. Is there any way to traverse to first step form the fifth step? I have created multistep form as given in example module. In the ...
4
votes
3answers
5k views

Form API to Database

I have been reading Form API Quickstart Guide. I understand how it all works, but I don't understand how to save the data entered into the forms into my own database Drupal style. Or am I supposed to ...
2
votes
2answers
14k views

Example for $form_state[‘rebuild’]

May anyone give me an example of rebuilding the form using $form_state['rebuild'] after user's input?
5
votes
1answer
495 views

How do I include ? and = in a form redirection?

I have a form and I would like to take the value from it, and use it as input for a page view which is created using exposed filters. I have created a submit handler for my first form. I then redirect ...
3
votes
3answers
2k views

How to get latitude and longitude from user with Form API

I want to create a database-driven website with Drupal 6 to gather some information from users that is related to the location; I want to create a form (and I don't want to use Webforms, or CCK) to ...
4
votes
2answers
4k views

How can I add an extra button & submit handler to an exposed view form?

I would like to add a second button to an exposed view form. I am able to get the button to display, but not to have it call the button submit handler. Instead, it behaves just like the standard ...
3
votes
2answers
3k views

Creating a form

I am new to Drupal 6. I have been playing around with the settings and have been able to create a static website. What I can't seem to figure out is how I create a form with some input fields and a ...
2
votes
3answers
336 views

Automatically fill the default vocabulary term associated with a content type when editing a node

What I'm trying to do is to automatically select the default term in the "add content" page based on the user's location in the site. Example: User is currently viewing classifieds listed under "Los ...
1
vote
3answers
632 views

theming a CCK input form

How do I theme a CCK input form? I tried the approach given in this page, but it is not working even after I clear the cache. Here are the steps. Suppose your content-type is: "account_registration" ...
1
vote
2answers
752 views

Save and preview differences in hook_form_alter()

I've created a module which uses hook_form_alter(). When a form is loaded (node/add) I hide a field, and the hook works fine. The problem appears when I do a preview of the form. When the form appears ...
3
votes
4answers
2k views

Combining two node forms: is that possible?

I am using Drupal 6 and I got a node form for a content type. I want to alter the other content type node form inside the first one; is that possible?
3
votes
1answer
449 views

How does form API work for CCK (and other #after_build processes)?

When you want to hook into a CCK form and alter something, you are usually required to call a custom function from $form['#after_build'] (right?). When doing so, I have noticed I can't write $form['...
1
vote
2answers
399 views

Can I expose the signup form through views 2?

I am using Signup and Views in Drupal 6 (I can't install Drupal 7), and I created a view that lists all the nodes for which users can signup. Now I want to enable users to signup for one of these ...
3
votes
3answers
3k views

How to add some JavaScript functions before Ajax begins

How do I add some JavaScript functions before Ajax begins, with FAPI? $form['submit'] = array( '#type' => 'submit', '#value' => 'Upload', '#ajax' => array( 'callback' => '...
2
votes
3answers
401 views

Alternative themed forms for a single custom content type

On a site I would like a "quick entry" form for a custom content type on the front page, while also keeping the "normal" non-customized "node/add/mycontenttype" form. I'm able to customize the "normal"...
1
vote
2answers
1k views

Email-only subscription form with mailchimp module?

I have a mailing list in MailChimp and I recently installed the mailchimp module in my Drupal 6.0 site. The subscribe form for anonymous users has first name and last name input elements, as well as ...
8
votes
3answers
8k views

Can I attach a jquery.ui.datepicker widget to a form element using the form api?

I have a generic form element: $form['date'] = array( '#type' => 'textfield', '#title' => t( 'Date' ), ); That I want to add the jquery ui datepicker to this element. Is there a way to ...
2
votes
2answers
169 views

How to avoid submitting a form when creating a new content, depending on some criteria?

Let's suppose I have a content type Person, and I don't want the field Name to contain the text AAA. What would be the best way of avoid submitting the form if that happens? For example: - Hiding ...
1
vote
1answer
662 views

Error class not being set on form fields

I have a complex for that for various reasons I am validating in the _submit hook instead of the _validate. This is working great with the exception that the error class isn't getting added to the ...
2
votes
3answers
1k views

Embed form inside a block

I am using a module (donate) that produces a form at a specific URL, for example, http://example.com/donate. I would like to put this form inside a block and display it on another page. Do you guys ...
1
vote
2answers
859 views

Last form validation function is passing an error even though the first one registers the user

I wrote a custom user_login form validation function that calls user_external_login_register() to register and login the user, but the last validation function for the form calls form_set_error(). ...
7
votes
4answers
10k views

Is it possible to redirect after “pushing” a file to the user?

I've got a setup where a site generates internal analytics about site usage. Users are able to request a download of their personal analytics, and because this information is sensitive I do not create ...
2
votes
2answers
233 views

Where to modify the logic that calculates the height of a collapsible fieldset?

I'm not sure if this is a theme issue, but I continually get my collapsible fieldsets being 1-2 scanlines too short, causing scroll bars to appear. This project has heavy use of FAPI, sometimes with ...
9
votes
3answers
19k views

Form Api File upload

I have the following code in my form. $form['new']['upload'] = array( '#type' => 'file', '#title' => t(''), '#size' => 40, ); On the submission handler, it returns the file name but ...
4
votes
2answers
2k views

Send a CSV file to the user on FAPI form submit

I have a FAPI form that collects some information from the user, then generates a CSV file. The intent is when the user clicks 'export' on the form, the CSV is downloaded straight away. However, when ...
3
votes
3answers
712 views

How can I add extra info to my menus?

I have some menus that are managed in the standard Menus module (Drupal 6, BTW). I want to add a checkbox when I'm editing a menu item to control the display of a "New" banner via CSS (by adding a ...
7
votes
5answers
12k views

how to overwrite the search box?

<div class="fr_search"> <form action="/" accept-charset="UTF-8" method="post" id="search-theme-form"> <input name="search_theme_form" id="edit-search-theme-form-1" size="...
2
votes
1answer
959 views

How to call a Rules action settings form via drupal_get_form

So, I'm trying to embed the form I find at '/admin/config/workflow/rules/reaction/manage/commerce_payment_paypal_wps/edit/3' - which contains the settings for the PayPal business, etc (from ...
13
votes
3answers
14k views

How do I add client-side form validation to a Drupal form?

How do I add client-side form validation to a Drupal form? For example, in the comment module. If the vistor don't enter the email address, I want to popup a window that says: "please enter the ...
6
votes
2answers
7k views

How do I resolve the “Argument 1 passed to drupal_attributes() must be an array” error on my system_settings_form()?

I don't usually post specific questions like this, and ask for help on a specific issue but I am at the end of my rope wasting time way... I have a simple D7 module as seen below, when I load the ...
31
votes
13answers
21k views

How can I disable a single checkbox in a 'checkboxes' FAPI element?

Title basically says it all, I want to disable a single checkbox of a checkboxes type FAPI element. I don't want to do if with JavaScript, nor is changing it from checkboxes to multiple checkbox ...
3
votes
2answers
2k views

How to expand the fieldsets in node-add form?

When I am adding new node by admin/content/node-type/story, there are a lot of settings ordered by groups: Submission form settings, workflow setting, comment settings. But all these fieldsets are ...
3
votes
2answers
665 views

How to output form element values as text?

On a node edit form, I want to make certain fields be non-editable by all users but the values stored in them to be visible on the form. My thought was to just print them out as text instead of in an ...
7
votes
3answers
2k views

How can I hook into the system Contact form Message Sent process and alter the HTML generated?

I have a Drupal site where I am using the sited-wide system Contact to allow visitors to send messages to the site owner. Once a visitor submits the form, the user is redirected to the home page and ...
6
votes
2answers
2k views

How should I handle container form elements?

I have added some custom fields to the register user form and I'm discovered that they are sent back, packaged in a form element of type "container". My code needs to handle all kind of different ...
3
votes
1answer
1k views

Node form redirect based on submit button value

I've read and experimented with several ways to redirect a form once submitted. However, I only want to redirect a node form if the operation is t('Save'). If I set $form['#redirect'] = 'blah' in ...
20
votes
4answers
8k views

Easiest method for conditional fields in a form

What is the easiest way to get some javascript magic for enabling/disabling form fields based on another field's value? This sounds like something there should be an helper for somewhere, but I can't ...
5
votes
2answers
7k views

Theme Drupal Form API checkboxes as a grid

I have a custom form that displays a form element of about 2 dozen checkboxes. I would like to output them 3 per row, in a table if possible. How can I go about doing that? $form['preference'] = ...
5
votes
4answers
3k views

Remove colons from Drupal form fields/labels

How can I remove the : from appearing after every label in forms made with the Drupal Form API?
6
votes
2answers
4k views

When should the “container” form element be used?

The System module defines the container form element, but that form element is not documented in the Form API Reference. When should that form element be used? What is its purpose?
49
votes
7answers
55k views

How to a use a template file to theme a form?

While nodes, comments, blocks and many other things in Drupal are themed using theme template files (like node.tpl.php), forms are a different story. There are no theme template files for forms. How ...
2
votes
1answer
299 views

Whats the best way to add an object to a form array?

What is the best way to add an object to a form array so that any form_alter hook can interrogate the form for the object and act accordingly. For example, I have an object I pass to my form which ...
7
votes
4answers
3k views

How to remove the default “Anonymous” from comment author name?

In the comment form field (core comment module) I would to leave the comment author name empty, in order to encourage commentators to come up with original epithets. What's the easiest way to do it?
22
votes
6answers
14k views

How to upload multiple files at once?

We need to upload multiple files of different types, is there a module that will check for valid mime types and upload only the valid files, (based on site settings, eg: png, doc, jpg, txt) ?