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

learn more… | top users | synonyms (1)

0
votes
0answers
7 views

Search API Custom autocomplete callback return field values

I am creating a custom form with an autocomplete callback that searches in my search index called client_index <?php function module_search_client($string) { dpm($string); $matches = array(); ...
0
votes
2answers
17 views

form_set_error() redirects to raw ajax response page

I have a page with a simple view. Above the view there is a menu link that when clicked loads a node form with a required file field. The form is fetched and loaded using ajax_commands into a div on ...
0
votes
0answers
17 views

Form submit with radio in table has data in form_state['input'] and not in form_state['values']

While developing a form for Drupal 7, I need a few radio groups, placed inside a table (one radio group per table row). The radios are defined as '#type' => 'radio' (not radios) and grouped ...
-3
votes
1answer
29 views

Fetch data from database and show in custom module's form [on hold]

I used the following code in my module to build a form : $form['promo_type'] = array( '#type' => 'select', '#title' => 'Promotion Type', '#options' => array(t('Digital Coupon')), ); ...
0
votes
1answer
24 views

Custom submit button callback overrides default callback?

I am trying to accomplish the following functionality: I have a profile2 registration form to which I have added a custom form element (just a submit button) using hook_form_alter(). The submit ...
0
votes
1answer
12 views

adding data attribute to option value in Drupal 6

I have a form, like this: $form['my_case_type_list']=array( '#type'=>'select', '#title' => 'Issue Type', '#options' => $my_list, ...
1
vote
1answer
22 views

How to add html to the form?

I am creating a custom module. I have a form that I would like to add some HTML to, but I don't know what the best way to do this. In this example, I have a page with a textbox, dropdown list, and ...
0
votes
0answers
50 views

How do I get ajax callbacks from working example to execute in Views handlers?

I can't seem to get a callback function to execute in Drupal 7 Views 3 argument handler. All I want to do is have one displayed form element change when the user changes another. Simple. This ...
0
votes
2answers
38 views

Make form to show multiple field widgets with predefined values

I have a node form with multivalue field (cardinality unlimited). I need to show user 3 widgets if this field with predefined value (like shown at screenshot). At screenshots I show the current form, ...
4
votes
1answer
44 views

How to pass Javascript variable with form on submit?

I want to pass a variable created with Javascript to $form_state so that I can use this variable in the form_submit function. In an ajaxified form I can use: ...
0
votes
0answers
39 views

Prepopulate field collection programmatically

I have a content type with field collection field (unlimited cardinality). Each collection has image field (required) and long text field. How can I prepopulate node form with multiple collections? I ...
1
vote
0answers
25 views

How to work around server limitations on form size?

I have a form pretty similar to one you can see on your own sites under http://example.com/admin/people/permissions - that is, rows with checkboxes. A lot of checkboxes. I used this code to count ...
0
votes
1answer
28 views

Using #states to disable a field collection field

I am trying to disable a date field's second value, inside a field collection, but it isn't working. My hook_form_alter has this: ...
5
votes
2answers
104 views

Difference between hide() and ['#access'] = FALSE

I want to remove the delete button from a standard edit form in certain cases and I'm looking for the right way to do that. So far I found that hide() marks an element as already rendered so it ...
0
votes
1answer
10 views

Drupal 6 Form fields not displaying if nested too deep.

I'm using Drupal 6 to create a form that's pretty big. Basically here is how the client wants this form to act: Users create engagements, and an engagement can have multiple goals and multiple ...
0
votes
0answers
31 views

Do not fire ajax on blur on textfield when a button is clicked

I have a textfield with autocomplete, ajax on blur, and a search button next to it: $form['order']['keyword'] = array( '#title' => t('Keyword'), '#type' => 'textfield', '#prefix' ...
0
votes
0answers
28 views

Form API managed_file video upload w/ thumbnails question

I am creating a custom form via the form API in Drupal 7. I need to upload a video with the option to select a thumbnail. Uploading a video is easy enough with the form API using the type ...
0
votes
1answer
16 views

How to create a custom field with a custom FAPI element?

I am writing a custom field module for phone numbers. The field has 4 different parts: A select element to choose the type of phone number, (phone, fax, toll free, other), A text field for the ...
0
votes
1answer
49 views

hook_form_alter isn't working

I've been trying to insert a placeholder for my search-bar, so in my page.preprocess.inc I call hook_form_search_block_form_alter(), then specify the form's array, and create the placeholder array, ...
0
votes
0answers
13 views

Tableselect radios are not accessible

Has anyone else run into an accessibility issue when using the form API tableselect element ('#multiple' => FALSE)? The resulting markup is a table with the first column as an input of type radio, but ...
0
votes
0answers
12 views

Ctools content type not responding to form api ajax callback

I am using a ctools content type plugins to render a custom form that will have only one submit button. The submitbutton will switch an eck entity field (boolean) from 0 to 1 and back (if pressed ...
0
votes
0answers
47 views

Assign values to dynamically generated textfield based on select option in custom form

In my below code i have dynamically generated fieldset. Each fieldset has select option field and textfield that are generated dynamically. Based on select option i want to fill textfield Eg. ...
0
votes
0answers
42 views

Ajax callbacks in a form retrieved by ajax

We have a list of themed nodes output on a page. Each node acts as an ajax callback to the edit form. The hook_menu definition for these links is: $items['rates/%/%'] = array( 'page callback' => ...
0
votes
0answers
24 views

Multiple radio buttons in different field sets

Been banging my head against this problem all day... I have a list of fieldsets, with a radio button in each that allows you to select one as a "default", the radio buttons work correctly in that only ...
0
votes
0answers
25 views

How can i use the Drupal form API states to make my field value depend on another field value?

Basically what I'm trying to do is to change the #autocomplete_path for the author field in the node/add. The value of the #autocomplete_path will be dependent on the value of another field (a select ...
1
vote
1answer
73 views

A Multi-step Form to display Database Data at the End

I'm fairly new to Drupal but I'm building a site using Drupal 7. Most of the stuff is pretty standard Drupal things, but one of the things my stakeholders want is a tool that does the following (and ...
0
votes
2answers
30 views

Removing required attribute on user entity fields not working

I have added fields to user entity and make them required and show on registration page. So the user signing up have to fill all the fields. On the admin side these all fields are coming but i don't ...
0
votes
0answers
36 views

How to call a JavaScript function inside the form_submit?

My problem is exactly as the title of my post shows. How should I call a javascript function inside the form_submit hook? I just need to call a function which is previously defined in a javascript ...
0
votes
1answer
25 views

Changing value of min / max resolution for an image field dynamically based on a previous select list

Does anyone know if there is a way in Drupal 7 to change dynamically the value of minimum / maximum resolution for an image base on a previous select list. Example : I have a select with 3 elements ...
0
votes
1answer
32 views

Numeric field type in Form API

I am trying to add a "number" field type to a form using FAPI: $form['phone_number']['areacode'] = array( '#type' => 'textfield', '#title' => '---', '#width' => '30%', '#align' => ...
0
votes
0answers
63 views

How to reindex $form_state values' deltas when deleting or unsetting one of the options?

In a module, I provide a form to the user to select a value from a select. The form allows multiple values and the form updates itself via ajax to provide always one more select field than selected ...
0
votes
1answer
28 views

Undesired toggle effect with #states and checkboxes

I'm working on a patch for the Login Disable module, and on the settings page, I want to have two mutually exclusive options so that when one is checked, the other is unchecked. Using the FAPI #states ...
2
votes
1answer
20 views

How to unset _none option inside field collection?

Normally, in a node form you'ld unset the _none option like so: function MYMODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) { ...
0
votes
1answer
20 views

How to create a form, using a function, located inside a class

Usually when we need to create a form we create a function inside module and call: $form = drupal_get_form('function_name'); drupal_render($form); Now I started using entities and created a ...
0
votes
3answers
49 views

How to print external html output in form_submit

I have written a form that accepts user's input and based upon the input queries an external site and extracts the html of the result page from the external site. Is there a way to print html inside ...
0
votes
1answer
22 views

selected option on drupal form not coming up first

I added a '#default_value to my drupal7 form , and it says <option selected="selected" value="81">Service</option> (this is the option I want selected) but I want it to come out first ...
0
votes
1answer
34 views

Request an Ajax form through Ajax [solved]

I want to load a form through Ajax in a custom Javascript Event as it is explained in this tutorial. I receive the form, but its ajaxified behaviour is very strange. My Javascript: var address = ...
1
vote
1answer
29 views

Set entity reference field in form to readonly

I am building a custom module to set default values for entity reference fields. To avoid overwriting these defaults, i would like to set the field readonly. While I got the defaults to work, setting ...
0
votes
0answers
23 views

Drupal Ajax Form and Output Toggle

I want to a a block with data, say DATA One DATA Two Edit Data When I click button Edit Data, It should replace data with form fields, i-e Field One and Field Two, with a submit button, after ...
1
vote
0answers
18 views

Updating multiple elements in Form Ajax Callback [duplicate]

The Form In a Drupal Form I have (amongst other elements): Two select lists: Retailers, Products. One Table select: Selected Products. Two buttons: Add, Remove The Functionality I want: The ...
2
votes
4answers
398 views

Populate multiselect options onchange of dropdown using AJAX

I have created a content type (Geological Locations) with 2 fields, Country and States. The Country field is a select box, and States field is a multiselect. So if i select a Country, the States ...
0
votes
0answers
41 views

Display search result in a form

I am building a simple custom module to search a certain node type and displaying it in the same page as the form. It is like the search function. The problem is how to display the result below the ...
0
votes
0answers
15 views

hook_form_alter logic only on certain buttons

I have an existing webform that I'm using hook_form_alter to prepopulate various fields on. It "worked" before I just added a new field. I just added a new Upload File field (a Managed file I believe ...
0
votes
1answer
20 views

Form elements as arrays #tree

So I'm struggling with the concept of trees in Drupal. I have a form that presents a user with a drop down of number 1 - 27 depending on what they pick the form renders out an equal number of text ...
0
votes
1answer
11 views

Dynamic Field Adition / Subtraction using FAPI

Goal Provide a user with a drop down menu defaulted to a value of none. Other options are the number 1 through 27. Based on the value select have drupal FAPI generate a fieldset that has anywhere from ...
1
vote
1answer
80 views

Form AJAX - Update button value via Ajax

I have a custom form in Drupal that ties into Entity-generating code. In essence, there's a button which should return an ideal Entity state (determined in a method that returns true or false). The ...
1
vote
1answer
138 views

How do I know when a render array will be processed properly?

I'm still getting to grips with render arrays and there similarity to FAPI arrays is a point of confusion. I'm customizing a node form using hook_form_alter and I wanted to insert some custom markup ...
0
votes
1answer
54 views

How to remove the submit button on the form included by drupal_get_form?

I have a hook_field_widget_form where I call drupal_get_form multiple times. Here is my code: foreach ($suppliers AS $supplier_id => $supplier) { $delivery_information = ...
2
votes
2answers
70 views

How to make a reset form button without type 'markup'?

My situation: I built a form with FAPI. I display the results in a table like this: function grap_contact_repository_form_submit($form, &$form_state) { ... $form_state['results_table'] = ...
0
votes
1answer
16 views

“Preview before submitting” based on user role

So, you can make "Preview before submitting" optional or required for a node type. I would like to make it optional based on the user who is creating the node. So, for example, a authenticated user ...