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

learn more… | top users | synonyms

1
vote
0answers
16 views

Use drupal #states to check a radio

I would like to translate some jquery .change functionality to use #states in the form api. var radio1 = jQuery('input:radio[name=radio_1]'); var radio2 = jQuery('input:radio[name=radio_2]'); ...
0
votes
0answers
11 views

Views - Unable to set custom form field value in Exposed form

I have a view with 2 exposed filters . one is the start date and the other is the end date. I need to programatically control the end date filter based on a checkbox. I added a checkbox to the exposed ...
0
votes
0answers
15 views

Form states is not working in jQuery 1.7 an 1.8 [on hold]

I've used jQuery Update 7.x-2.4, jQuery 1.7 I have tried to alter user register form using hook_form_alter() and used states. But I can't get this work. It is working only if jQuery 1.9 and 1.10. I ...
0
votes
2answers
27 views

Drupal Form in Block will NOT call Submit or Validate handlers

Let me start by saying I have seen quite a few similar threads, and I have tried everything I've found so far, with none of them working. My brother wanted a contact form to be in the footer of his ...
0
votes
0answers
14 views

Changing configuration using form

I have created a form using which I want to make changes in the configuration.Currently I am submitting form doing something like this: public function submitForm(array &$form, ...
0
votes
1answer
16 views

How can I remove “please wait…” from a form?

I saw this Remove the "Please wait" text on Ajax Call but I can't find the form element. <?php dsm($form);?> and <?php dpm($form);?> return errors. This is what I found in $node: ...
0
votes
0answers
17 views

It is possible to use FAPI #states on hidden elements?

I want to enable a submit button based of a hidden input value. Right now i have this but it does not seem to work. $states = array(); $dependencies = array(); foreach ...
0
votes
1answer
24 views

Submit not executed

Why is my submit function never been executed? /** * Implements hook_menu(). */ function simpleexample_menu() { $items['simple-example-page'] = array( 'title' => 'Simple Multi-Step Form', ...
0
votes
1answer
18 views

How to add custom content before hook_form()

Form uploads image and if image is uploaded I'd like it to be displayed before the form. What is the right way to do this?
1
vote
0answers
31 views

How can I find which modules alter my form?

Is there a way to debug the list of modules which alters my form (using form_ID). I can get a list of modules implementing hook_form_alter using module_implements('form_alter') but how can I know ...
0
votes
1answer
24 views

How to pre-select items in a select with chosen

How do you load a select with items preselected when the chosen module is installed/enabled? I'm doing the following: $my_list = array('item1' = 'item1', 'item2' = 'item2', 'item3' = 'item3'); ...
0
votes
0answers
22 views

Reuse form from another module in multistep form

I have built a multistep form, and it works fine. Now I have installed LoginToboggan module, It has the option of show a unified login/registration form. I would like to set the last step of my ...
0
votes
0answers
16 views

Way of creating entities during submit handler of another entities

I'm creating a module that defines two entities. Let's name them entityone and entitytwo. Entitytwo contains reference to entityone. What I'm trying to achieve is to create entitytwos during creating ...
-1
votes
0answers
7 views

Combining a view and form on the same page [closed]

I would like to have a page that shows all of the users of a certain type and also includes a form that would allow the administrator to add more users of that type. Is it possible to do this with ...
0
votes
0answers
21 views

How to upload images in form - Drupal 6 [closed]

I want to create a form with 2 fields for uploading 2 images. I have read some examples on internet and doing everything by them. Problem is that the form is acting like there are no files selected ...
0
votes
0answers
18 views

Drupal 7 form only submits when logged in

I've built a form with Drupal 7 FAPI and it works perfectly, but only when I'm logged in as an admin. Otherwise, if you try to submit it without being logged in the page just refreshes when submitted, ...
0
votes
1answer
26 views

Access values from multiple field forms as elements of one form

I'm trying to create entities from my custom form. To do that, I created "Add more" button, where I'm dynamically adding new elements that I'm attaching fields to by using: ...
0
votes
1answer
16 views

How can i add a span element within the search form using hook_form_alter?

I’m trying to customize a search box that appears in the global header, using hook_form_alter. I’ve succeeded in changing the submit button to an image but still need to do the following 2 things: ...
0
votes
1answer
17 views

On node edit form, how to edit field from a referenced entity?

I've got a master entity (node) that users edit, and I've got an entity reference on it. I'd like to be able to edit a field on the referenced entity on that master referencing entity's edit form. Is ...
3
votes
1answer
27 views

Grab Data from non form elements and send as POST using AJAX

I am looking for an alternative solution to the way my form is being submitted right now. The problem is that the validation function does not work because I gave the submit button on the form an ...
1
vote
1answer
13 views

Wrapping div around form

function gng_unsubscribe_form($form,&$form_state) { $form['email'] = array( '#title' => 'Email', '#type' => 'textfield', ); $form['submit']=array( '#type'=>'submit', ...
1
vote
2answers
28 views

Get Div's Text in Drupal Forms API

I have this code below: $form['id']['mypreview_modal'] = array( '#type' => 'item', '#markup' => '<div id="mypreview_modal" title="ID Preview">12345</div>' ); ...
0
votes
0answers
22 views

Multiple Fields Custom Form not saving default values?

I tried to create multiple fields with values on it using custom form which allow users to add data as many as possible. and then I can populate from there, but I tested submit and the default value ...
-3
votes
0answers
24 views

Checkbox with key as 0 unselected automatically

as you can see in my question In my checkboxes if i have a 0 value it select this checkbox i solve my problem but now if i select emergency with key == 0 it also unselect this checkbox any ideas??
0
votes
0answers
9 views

#states not detecting a change to form via ajax_command_invoke

I have a form. On an elements I have an ajax call back. In the callback I use the commands[] to update some elements on the screen. One of the elements I update is used by another form element using ...
0
votes
1answer
24 views

Overriding user profile form

So I have this function: /** * Implements hook_form_FORM_ID_alter(). */ function my_module_form_user_profile_form_alter(&$form, &$form_state, $form_id) { dsm($form); } What I want to do ...
2
votes
1answer
23 views

In my checkboxes if i have a 0 value it select this checkbox

I have in my form a type 'checkboxes' form. // Form for the severity checkboxes. $kkkk_severity_levels = variable_get('kkkk_severity_levels', array()); // Declare empty options array. ...
0
votes
2answers
14 views

Configuration form settings

I would like to create a settings page for a user which allows them to save the options of a list which is to be used in a custom form. The list is called marketing source and it is added to a form ...
0
votes
0answers
6 views

How to add KnockoutJS to Drupal forms?

Does anyone have experience on adding front-end framework to Drupal? From my experience I see few problems FAPI and field/input attributes for KoJS dynamically added inputs: fapi doesn't allow ...
0
votes
0answers
19 views

I have a huge problem with the form

I want a form with checkboxes that will have all the severity levels and when the user (e.g selects only the error i want to select only the errors from watchdog. My problem now is that in watchdog ...
3
votes
1answer
58 views

How can I apply some value with HTML tags to a form element?

I've assigned some value with HTML tags to a form element, say the element is called name. When it returns the form, it exactly prints the value along with the HTML. What I want in return instead, is ...
0
votes
3answers
33 views

How to find the default value or change state of a Drupal 8 form element?

I'm putting together a fairly complex form with Drupal 8 (currently building on beta 7). In my validation function, I need to be able to detect whether a field, which was populated with default ...
0
votes
1answer
38 views

What is wrong in my code for replacing the text of 'add to cart' button?

Can somebody tell me what is wrong in my code, please? I'm trying to replace the regular text for 'add to cart' button for two types of product. I'm using Drupal Commerce module. But something is ...
0
votes
0answers
19 views

How to add text with summary field in drupal?

I am using drupal form API to create my form and want to create a text with summary field but when I use the type text_with_summary, nothing shows up in the form. For now, I have used two separate ...
0
votes
0answers
45 views

Change form_state values with custom ajax call but without #ajax commands (fapi)?

(Sorry for my bad English) I’m building multi steps form with help of FAPI in front-end section. In the final step of my form I want use some third party js libraries for few task (like uploading ...
1
vote
0answers
11 views

“managed_file” type element not showing in my custom block configure form

I have been creating a portfolio section for my one page theme and I created a module for these section blocks. Now, I'm using the hook_block_configure to set the data into the blocks. Only 1 ...
0
votes
0answers
26 views

Validation loses ajax form changes

I have a custom form. On an element on the form I have an ajax callback: $form['test'] = array( '#type' => 'textfield', '#title' => t('test'), '#ajax' => array( ...
0
votes
0answers
8 views

How to insert an entityform in a custom form?

I'm building a multi-step form in Drupal and in one step I want to insert the fields of an entityform. What I've done is: module_load_include('inc', 'entityform', 'entityform.admin'); $entityform = ...
0
votes
2answers
15 views

Results table with form select for filtering

I have a page set up via a custom module, which contains some data rendered in a table, not using views. I didn't use views because it requires some various calculations that views calc couldn't do. ...
0
votes
1answer
41 views

Ajax Callback Function in Submit Button Doesnt Work

I have a submit button in my form and I want to implement it using ajax: function myid_user_page_form(){ drupal_add_library('system', 'drupal.ajax'); $form = array(); $form['id'] = ...
0
votes
2answers
29 views

Call a Javascript Function and Update my Form Element at the same time

This is my ajax callback function function myid_search_idnumber($form, $form_state) { return $form['id']; } It updates the values in $form['id']. But Because I wanted to call a javascript ...
1
vote
1answer
20 views

$_FILES superglobal array key is not what file.inc expects

I'm trying to do some custom stuff with a file upload field via the form API. I call to file_save_upload() but it thinks that the upload is empty because it's examining $_FILES['files'] but for some ...
1
vote
1answer
20 views

Using #states API with an image field as a control field

On a form, is it possible to use #states to hide/show a field based on whether or not an image field has been filled in? More specifically, I'd like to get this node form: to only show the "Show ...
0
votes
0answers
27 views

function added to ['#submit'] of user_login form is not invoked

So, i have this project which has ton of custom code for authentication, cookies, 3rd party authentication & login tracking. Now, i have to enable TFA. Everything works after enabling TFA module ...
0
votes
1answer
12 views

Is a custom module the best way to build out a Form with full custom AJAX?

I have a project (problem) I've been thinking about for about a week now. When it was first presented to me it seemed to be a very easy solution, and frankly there are easy ways to accomplish this, ...
0
votes
0answers
36 views

Unzip a file in Drupal 7 Form API and upload extracted files

I'm creating a custom form using Drupal 7 Form API, and I need my users to be able to select a ZIP file containing a number of other files. I'd like to be able to extract the files and then upload ...
0
votes
2answers
15 views

I want a Notice message when save configuration [closed]

I have a module and a form with a checkbox...What i really want is when the user press the button save configuration to take a notice message..Could anyone know how to do this thing? foreach ...
0
votes
0answers
24 views

Jquery Plugin Doesn't Work when 2 Customized Modules are Enabled

I have two customize modules and they both use a Jquery Plugin: Barcode Generator. First Module function myid_init() { //Barcode Plug-in drupal_add_js(drupal_get_path("module", "myid") . ...
0
votes
1answer
32 views

Pre-Populating a Form Field with something other than its default value

I'm having a strange problem. I am constructing a form with checkboxes to toggle email subscription preferences on and off. For the new user sign-up form, this is straightforward: ...
1
vote
1answer
37 views

radios options separated into different wrappers

I'm trying to customize a radios field to wrap some of the options into a div. What the best way to do it? I had a look to theme_radio but no success on it :( example: <div id="part1"> ...