Questions tagged [drupal-fapi]

The Drupal form API is a very strong, robust, easy and scalable API for creating forms in Drupal.

The Drupal form API is a very strong, robust, easy and scalable API for creating forms in Drupal.

Documentation about the form API can be found on:

Related documentation

196 questions
14
votes
5 answers

Checking whether a user already exists in drupal

When a user enters his login information and hits submit, i want to check if the user already exists or not. So, i have the following two questions 1. Which hook is needed to be implemented , for the case when user hits the submit button on the…
simonr
  • 141
  • 1
  • 1
  • 3
13
votes
2 answers

Drupal form validation not working for me

I am trying to modify some Drupal 6 form code and incorporate some native form validation. Code looks like this, but validation does not work. I never even get into function thisFormName_form_validate. Any Drupalians have some good ideas?…
harry_T
  • 285
  • 2
  • 3
  • 11
12
votes
3 answers

drupal: Form API, dynamically hide or show fields based on input

I'm building a form module. One of the early fields is a set of radio buttons. By default the first button is selected. Next I'll have a series of select boxes. One needs to be visible, the others invisible. Then as the user selects a different…
LoneWolfPR
  • 3,978
  • 12
  • 48
  • 84
10
votes
6 answers

In Drupal 7 form API - How do I create an input of type "button" (not "submit")?

I am trying to have a button which is not a "submit" type of button, but rather a normal "button" type, using the forms api of drupal 7, but I can't seem to get it. I've tried many things, like setting #type to 'button', setting #button_type to…
Doron
  • 3,176
  • 7
  • 35
  • 60
9
votes
5 answers

Is there any way to get uid from user name in Drupal?

Is there any core function to get uid from username in Drupal? Or I should perform a db query? my field is a textfield with '#autocomplete_path' equal to 'user/autocomplete'
Nick.h
  • 4,035
  • 5
  • 21
  • 22
9
votes
4 answers

Drupal 7 - input form readonly and apply style

I need to apply style and read-only property to an input element of a drupal form. I coded the following: $form['precio'] = array( '#type' => 'textfield', '#title' => t('Precio'), '#default_value' => ''.$precio, '#size' => 20, '#required'…
Daniel
  • 2,371
  • 3
  • 15
  • 14
7
votes
3 answers

Adding attribute to option element using forms api : drupal 7

I want to add title="icons/icon_cart.gif" for each of the below options in my select list which is rendered using views. After trying and reading many articles I can't seem to find the way to add this html into my form. Below is my code. function…
Vishal Khialani
  • 2,557
  • 6
  • 38
  • 49
7
votes
3 answers

Form submit handlers with additional arguments

For some requirement I need to pass additional information to form submit handler. In form api, while defining custom submit handler as $additional_args = array(); $form['#submit'][] = 'my_submit_handler' I expect to submit handler as function…
Shoaib Nawaz
  • 2,302
  • 4
  • 29
  • 38
7
votes
5 answers

Drupal: How to Render Results of Form on Same Page as Form

How would I print the results of a form submission on the same page as the form itself? Relevant hook_menu: $items['admin/content/ncbi_subsites/paths'] = array( 'title' => 'Paths', 'description' => 'Paths for a particular…
Aaron
  • 3,249
  • 4
  • 35
  • 51
6
votes
1 answer

How to update the value of a single field invoking appropriate validation

I'm making a module to allow users to update single fields on in this case, their user entity. The code below is an example of the method I have initially been using to get it working and test other elements of the module global $user; $account =…
joevallender
  • 4,293
  • 3
  • 27
  • 35
6
votes
4 answers

How can I disable a Drupal form submit button when it is clicked to prevent double submission?

Sounds like a simple question. I've added a bit of jQuery magic: $("#edit-save").click(function(event) { $(this).attr("disabled", "true"); }); However, once this is in place, my form submit handler doesn't get called. This is a custom form on my…
Mark B
  • 4,768
  • 2
  • 25
  • 30
6
votes
2 answers

Drupal hook fired after node created

When I create a node I want it to programmatically create some nodes that reference the node just created. I though I would just need to change form_alter submit function for my form to call a custom function to create the nodes. Examining the…
Linda
  • 2,227
  • 5
  • 30
  • 40
6
votes
5 answers

How to override form just on one page?

OK so this is my hook form alter function.It is causing all the registration forms on site to be over written which I do not want as I just want it on this page. function special_registration_form_alter(&$form, $form_state, $form_id) { if…
user363036
  • 319
  • 1
  • 2
  • 7
5
votes
3 answers

Drupal Custom Node Form

I want to create an input form for registered user, separated from admin's content creation form. Each submission will create multiple node. To illustrate the case, I will use content type Project, and Review. Project: Title, Description, Owner,…
Ferry
  • 250
  • 3
  • 8
5
votes
1 answer

how to override a web form submit function in drupal7?

I have a web form with name and email fields. when the form is submitted the name and email should store in database and an PDF file should start download. my question is how to override the submit function of the web form so that i can add that…
user1900662
  • 299
  • 1
  • 7
  • 26
1
2 3
13 14