drupal-forms

AJAX in Drupal Forms?

How would you go about constructing a step by step form that uses AJAX through Drupal to pull the next form step? For example, Step 1: I like Baseball I don't like Baseball. When that person clicks on either Like or Don't Like, I want to use AJAX to recognize and pull the next part of the form, remove/hide the first section sin...

Remove the red outline on form elements that fail validation in drupal

When a drupal form fails validation, it is redrawn with the elements that failed validation surrounded in a red border. Drupal does this by adding the error class to the input elements, and specifing a 2px red border on input.error elements in system.css. Without modifying this stylesheet, how can I remove the red border on a specifi...

Drupal dynamic field type toggle

I have a form field in Drupal which I need some help with. The requirement is to have the field show up as a simple input field, but to have a toggle button against it which would convert it into a multi-line text box for users who wish to enter more data. In traditional PHP/HTML/Javascript this would be dead easy -- two fields; one st...

Redirect form in validation fail

I have a situation that if my form doesn't validate I need it to remove all but the first argument from the url. The reason for this is because the results of my form are displayed below the form in the content area. If the form doesn't validate I need to remove any previous results. I am have tried the following in my form_validate fun...

How can I get the title of a form element in Drupal?

For example, in the registration form, there is "Username" and the text field for it which has the input type="text" name="name" .... I need to know how can I get the title from the input field's name. I'm expecting a function like: $title = get_title_for_element('name'); Result: assert($title == 'Username'); // is true Is there ...

How do I get Drupal to add AHAH behaviour to a form element that is returned via AHAH?

So here's what I'm trying to do: 1. I create and render the following form element: $form['rb_download_' . $doc_id] = array( '#type' => 'submit', '#name' => 'doc_' . $doc_id, '#prefix' => "<div id='rb_doc_order_{$doc_id}'>", '#suffix' => '</div>', '#value' =>variable_get('rb_order_button', "buyOnline")...

drupal form api for radio button help needed

hi, i have to show a custom form like below either upload image or paste a url for the image O Radio button to set for image upload -------Input field for image upload OR O Radio button to set image url --------- input field to get that url im struggling with custom form code whether to use #type=>radio or #type=>radi...

Drupal: send output to user in form's submit handler, instead of redirecting

Hi, I have this basic Drupal scenario and question: I have a form which accepts some input from user, and a submit handler which should process data and show the result to user. In other words, I don't write anything in database or set e variables etc., just show some output to user. I was wondering how I can do this, because a submit h...

Drupal Form API: Create Form Elements based on the database values (Dynamic Form Creation)

Hello Everyone, I am creating a form where i have to populate "X" form elements (text-fields to be specific) based on values in the database (X number of elements, properties of each element etc). Is there a way to do this using the Drupal Form API or should i start from somewhere else. I tried using a for() loop in the form generating...

Using Javascript (Google Visualization API) with Drupal Form API

The situation I am implementing a few forms using the Drupal Form API. As a result of user selection i need to display a visualization (area chart, time line, etc) where i have to load the google's JS libraries and send data to display the visual in a div element. What I have Done: I have tried to load a local JavaScript file(this in...