Questions tagged [forms]

Use it for questions about the Form API. Don't use it for entity or entity field forms.

Filter by
Sorted by
Tagged with
3
votes
1answer
4k views

Get variables from checkboxes

I'm creating my very first Drupal module (Drupal 7, btw) and I'm almost done with it. There is one last thing and that is that I need to get the values from multiple checkboxes. My module list ...
1
vote
1answer
2k views

Drupal 7 Webform settings: how to change the default text in button “next page”?

I have created a webform with drupal 7 with two pages with "pagebreak" field, but when i go in mysite webform and i view the webform at the bottom of the page there is the button "next page": i have ...
2
votes
1answer
173 views

How do I add a span class to form item title in register form?

'#title' => t('I have read and agree to the') . "<b><a href='/terms' target='_blank'> terms of service</a></b>", How do I add a span class to the whole title, so It would ...
4
votes
3answers
1k views

Node creation with parameters

I have a form that when submitted and validated, needs to be redirected to a page to create a node (node/add/factura-tmn), but I want to send a parameter to this page. Is it possible? I currently ...
3
votes
1answer
412 views

Add Additional Submission Processing To “Create Node” forms

Which hooks can I implement in Drupal 7 to add additional processing steps to the node creation process. For example, to run a snippet of PHP code after the node has been successfully saved to the ...
4
votes
1answer
579 views

Drupal pager, go to specific page

I have a form in pager, so user can enter page he want's to view. But I can't figure out how to go to that page number in form submit.
4
votes
1answer
3k views

How to display messages from a block separately from $messages in page.tpl.php

I have a webform which works as a newsletter subscription form: it displays a textfield for an email and a button. When the button is clicked, a notification message is displayed on top of the page ...
5
votes
2answers
823 views

How to display URL in status message?

I want to customize the status message after creating a content to include the current URL. From @type %title has been updated. to @type %title has been updated. Your permalink is (URL) I'm ...
8
votes
2answers
12k views

Multiple forms on single page?

Is it possible to put multiple forms on a single page? I am trying to make a coupon offer page. I wanted to have two forms for two different offers on each side of a page. Each form has a text field ...
0
votes
1answer
170 views

Why isn't the code in my implementation of hook_form_alter() being called?

When I test to see if my form is called by checking for its $form_id, there is no output. Why is it that under the comment form it can't invoke the mymodule_ask_form? /** * @Implement of ...
1
vote
2answers
404 views

Display User Relationship request dialog on content profile page

I need to create an 'add friend' link programatically. $content .= '<li>' . l('<span class="icon"></span>Add to your friends', 'relationship/' . $tid . '/request/1?...
2
votes
1answer
560 views

Inserting Fields from A Custom Content Type into Custom Form

I created a custom content type called 'Building Location' that contains a custom field called 'US_States'. Is there a way I can access and include the 'US_States' field into a custom form I'm ...
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 ...
1
vote
2answers
867 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(). ...
0
votes
2answers
966 views

Form API select list remove blank entry (default select an entry)

I populate an select list using the following code. $getCompanies = 'SELECT nid, title FROM node where type = "my_type"'; $companiesResult = db_query($getCompanies); $companyArray = ...
0
votes
1answer
561 views

Detection of form refresh and callback!

How is it possible to detect if the page, in which the form is, is refreshed and to detect if only the form is refreshed? I tell you the whole thing: I'm building a module. The form in this module ...
1
vote
1answer
985 views

process form in popup window

I have a custom module in Drupal and I also have a custom table for storing the details of seminars, such as name, description, date and location. I am showing the names of the seminars in a left ...
2
votes
1answer
3k views

altering form with hook_form_FORM_ID_Alter

function dental_form_simplenews_block_form_2_alter(&$form, &$form_state, $form_id) { global $user; $form = array(); $form['#attributes'] = array('class' => array('newsletter')); ...
0
votes
2answers
3k views

Change the e-mail value during user registration ? form_set_value()

I have a custom module (entitled ta_module) : in the user registration form, it hides the e-mail field, and add a custom field where user have to enter what's before @ and then choose his e-mail ...
3
votes
2answers
2k views

When using hook_form_alter() and additional submit functions, can one reference a php file for the submit callback?

The following code works. function bleh_form_alter(&$form, &$form_state, $form_id) { switch ($form_id) { case "webform_client_form_13": $form['#submit'][] = '...
2
votes
2answers
4k views

Using AJAX in Drupal 7 to change a form action

I would like to update the Drupal save_edit module to add an auto-save feature. This would look similar to the Stack Exchange auto-save (draft saved). So far I've gotten the save portion working (...
1
vote
2answers
1k views

How to hook to content profile edit form validation

I try the following code, but it doesn't seem to work. function mymod_profile_node_form_validate($node,&$form) { firep($form, 'form'); } Could anybody help?
3
votes
3answers
1k views

Secondary submit function for form input button

I want to have buttons for remove selected field from form. $form['questions']['buttons'][$counter] = array( '#type' => 'button', '#name' =>'button_'.$counter, '#...
1
vote
2answers
264 views

How to expose individual form elements from user-register-form

So I have a work flow/use case as such: an administrator user creates a user account, associating it to the "guest" role the guest users receive a login link once they log in, I want them to provide ...
6
votes
2answers
333 views

Difficulties with the #ajax form item attribute

My form item is the following one: $form['foo'] = array( '#title' => t('Foo'), '#type' => 'radios', '#options' => $options, '#description' => t('Lorem ipsum.'), ...
3
votes
3answers
124 views

How do I better play nice with weights, when overriding a form?

I'm attempting to use the Constant Contact module. One of the features of this module is that it inserts a check-box into the user registration form. The problem is that it seems to set weights in a ...
2
votes
2answers
3k views

How do I call an implementation of hook_form_alter()?

I have a function in my module that implements hook_form_alter(): function getuserform_form_alter(&$form, $form_state, $form_id). How do I call it? How do I pass it the required parameters?
0
votes
1answer
735 views

Ideas on how to create a multi-part form, where the form requires completion/approval by another user

Desired form submission workflow: User A fills out a form, along with an email address for User B User A submits the form, which then notifies User B by email of a request to complete and approve the ...
0
votes
1answer
891 views

Run javascript code on Form Submit

I want to run JavaScript code upon a form being submitted preceding other default tasks that are carried out on form submission. May anyone suggest some approaches?
0
votes
1answer
586 views

How do I modify the content of a select list field?

I have a content type with a Node Reference field, so the user can select from a list of node titles. I need to filter out some nodes from the list (those that have a date field older than the current ...
0
votes
2answers
117 views

Administrator users can add records, end users can view them

How can the administrator users add few records into the database (through a form), and how can the end users view them in the front end? Administrator users will be adding records of training ...
0
votes
1answer
890 views

Create Forms in Drupal and process them

i am new to Drupal and i want to implement training / seminar program in my Drupal site. I want to know how to implement the following features: The administrator will be creating a seminar / ...
1
vote
1answer
663 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
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 ...
0
votes
1answer
4k views

Error using form API on AJAX submit

I am writing a form using the Drupal 7 form API. On submitting the form (via AJAX), the following error is displayed: An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information ...
2
votes
1answer
624 views

Updating a field value in database via submit handler doesn't update the user profile in UI

I've created the field "Attending" that is attached to the user profile. I have created a form with one checkbox element; when submitted, I've confirmed that the attending_fielddatabase is being ...
1
vote
2answers
512 views

How to tell the difference between multiple image_buttons on the same form?

Using FormAPI to create a simple set of three image_buttons, in the form_submit handler there is no 'op' value set in $form_state and therefore no way to tell which image_button was clicked. Is this a ...
0
votes
2answers
3k views

How to overwrite the add content page

I created a content type "test", and I want to overwrite the add "test" content page (http://www.example.com/node/add/test); for example, I want to show something on the right part of the page. How ...
1
vote
1answer
443 views

Form, populate select lists values after unsuccessfull validation

I would like to have select values in my select lists that user poster to script. However when validation is not valid, those fields aren't populated with posted data, so user have to make the choice ...
2
votes
1answer
867 views

Form submit problem

I have no idea why my form submit only work if I put on screen values of $form argument. If I add: echo '<pre>'; print_r($form); echo '</pre>' to my submit function I am getting new '...
2
votes
2answers
303 views

Best approach for [back][next] form submitting

I've been doing a [back][next] to [finish] set of forms for user input fields, think of it like a questionnaire for user info where the user can still go back to the previous pages to update their ...
1
vote
1answer
2k views

FAPI 'radios' don't respect '#default_value'?

I noticed that the 'comment settings' radio buttons ('#type' => 'radios') were not respecting their default value settings in my content types. I have several module created custom content types, as ...
2
votes
1answer
142 views

Putting a form into a menu

I've started learning Drupal (I'm starting with Drupal 7) and the best way to do that seemed to me to be in creating a custom theme from scratch. I'm trying to create a menu in which the login form ...
5
votes
3answers
147 views

Is there a module for site explanation messages?

Many sites have text areas which appear to explain things to new users. With an option to hide the message in future. I haven't seen such a module for Drupal, does one exist? I have tried googling ...
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 ...
1
vote
2answers
779 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 ...
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 ...
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 ...
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
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 ...