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

learn more… | top users | synonyms

0
votes
0answers
12 views

how to have admin settings form and add content form? [on hold]

I am new to Drupal, i create custom module. content form is created and working fine, but now i need to have the second form which is Settings form, the menu Hook is setup and my module appears in the ...
0
votes
1answer
21 views

Ajax Callback Function Not Working in A Button

I have one select element, that calls an ajax callback function when it's value changes: $form['myid_template']['template_options'] = array( '#type' => 'select', '#options' => ...
0
votes
0answers
9 views

Form api empty value (#empty_value) overwrites index of a select option - how to stop it?

I want to use the empty value ('#empty_value') property of the $form api array for my select list element. My options are keyed as per the PKs of a table and values are the 'description' One of the ...
0
votes
0answers
11 views

Changing field type to text_format via hook_form_formid_alter loses data when trying to edit form

I have a content type named "job posting." On this content type I have several long text fields, but I want to use a WYSIWYG on those fields, and I want to filter the WYSIWYG's HTML. Using ...
0
votes
1answer
18 views

Create interactive search filter

I need to develop a search form with two differents taxonomy (taxo1,taxo2). When a user selects in taxo1 la term, the second list has to be shown with inside only corresponding taxonomy terms. Here ...
1
vote
0answers
32 views

Alter an existing form

We just starting out with Drupal 8 and very quickly we ran into our first problem. What is the best way to alter an existing form in Drupal 8? We need to alter the save method for the node form to ...
1
vote
0answers
28 views

tableselect checkboxes

i want to change values of only checked elements on tableselect. How can i do that please ? this is my tableselect : $form['tab'] = array( '#type' => 'tableselect', '#header' => ...
0
votes
1answer
17 views

Moving a number of fields into a table on D7 node form

I have a form with three field groups, arranged as horizontal tabs. On one of these tabs, I have twelve fields. For eight of these fields, I would like to arrange them inside of a table. These ...
0
votes
1answer
25 views

how to make multiple ajax callbacks from a drop-down field?

I have a select field in my custom module (Drupal 7), which needs to refresh the values of 2 different field types when a value is selected, firstly a checkbox field, which currently is refreshed ...
0
votes
2answers
29 views

call external form in ajax callback

I have two forms (A & B) in custom module. Form A containing three fields(each field is dependent drop down) and Form B containing only one field (markup field to show data). The problem is that ...
0
votes
0answers
13 views

Drupal 7 Form API Date input as multiple text fields

Using the form API how can I create a date input with multiple text fields like this? The Date module offers a few input types but they are limited to a single text box (rather than three), select ...
0
votes
1answer
13 views

Ajax form in block

From my experience, I believe Drupal8 treat Form API in BlockBase differently from FormBase Class, the below block doesn't seem to work. Do I have to do anything else to make Ajax Form work in Block? ...
0
votes
0answers
16 views

Embed a Select Form Control in a Modal

I have a select form control. $form['options'] = array( '#type' => 'select', '#options' => array( 1 => t('One'), 2 => t('Two'), 3 => t('Three') ), ...
0
votes
2answers
20 views

Drupal 7: use Form API to make a button that doesn't submit the whole page [duplicate]

I want a button that runs a callback function using the AJAX method included in Form API. The button I have still submits the whole node edit form. I don't want it to do that - just pass a couple ...
0
votes
1answer
28 views

Embed a form inside a modal

I have a modal in my form. $form['myid_print_preview_modal'] = array( '#type' => 'item', '#markup' => '<div id="myid_print_preview_modal" title="ID ...
0
votes
0answers
17 views

hook_form_alter() adding ajax event

I have a custom module that is adding a new field in the form in hook_form_alter(). In my hook_form_alter() I have function mymod_form_alter(&$form, &$form_state, $form_id) { ...
0
votes
0answers
14 views

System settings form not saving weight with table drag

I am trying to do a table drag, and the table drag is working, but the weights don't seem to save on form save. Here's my form: function lextext_admin_settings() { $form = array(); $lextext_info ...
0
votes
0answers
15 views

How to set value to auto-complete field after form submission?

I have a dependent auto-complete form field in my custom module. After submission the form the auto-complete field shows above the result output. Now I want that submitted value should become default ...
0
votes
0answers
7 views

How do I take out or hide only one of the optgroup tags that I am using?

I have tried using #post_render by adding div tags around the optgroup tags. The idea was that this would take out a specific optgroup when the javascript event arises, but I tried this with no ...
-1
votes
1answer
53 views

Not able to get textfield value to generate a ajax dependent dropdown option

I am not able to get the textfield value to generate an ajax dependent dropdown option.That is when i am trying to enter a textfield value in the form and clicking a button to call the ajax function. ...
1
vote
1answer
14 views

Can I show an image in place of a Drupal 6 message?

I have a form, that upon completion, goes back to the page it was called from and displays a message of success when everything is done. Is it possible to just display an image on that same page, or ...
1
vote
0answers
21 views

Submitting a form causes 'secure connection failed' error that persists

I've got a SSL certified server running drupal 7.37. Everything was working fine until I started adding form submission to a module I'm working on. As soon as I submit the form, I get 'Secure ...
0
votes
1answer
20 views

custom wrapper to a form api field [closed]

In form api, #prefix and suffix are not working for '#type' => 'managed_file'. Below is my code, is there any other way to wrap this? $form['cvFile'] = array( //'#title' => t('Upload ...
0
votes
1answer
9 views

How do I do a file upload with other form data in Drupal 6?

I have this in my form function: $form['#attributes'] = array('enctype' => 'multipart/form-data'); ... other form fields $form['form']['form_file'] = array ( '#type' => 'file', ...
1
vote
1answer
29 views

Redirecting doesn't work with a custom form in a block

I developed a custom form with FAPI and added a block for it. Block is included only on one specific page (basic node). When user submits this form it should redirect user to external site (URL is a ...
0
votes
2answers
23 views

How to Disable Whole Form from hook_form_alter?

I've got a form I want to be disabled when certain criteria are met. According to the Form API I thought $form['#access'] = FALSE; would be sufficient. But no dice. Instead, I'm doing this, which ...
0
votes
1answer
40 views

Conflict between ajax callback and jQuery UI dialog

I have a button that triggers an AJAX callback with the form api like so : $form['show_modal'] = array( '#type' => 'submit', '#value' => t('Some crazy text'), '#ajax' => array( ...
1
vote
1answer
20 views

Programmically populate select list with hook_form_alter [closed]

I have no trouble populating other fields, but am struggling with populating a select lists #options. Anyone know of a slick way of going about that or have any good reference material?
1
vote
1answer
29 views

Ajax callback returns value but wrapper isn't filled

I'm stuck because whatever I do my wrapper is never filled with my callback, any idea ? $form['show_liste_produits'] = array( '#type' => 'button', //'#attributes' => array('onclick' => ...
0
votes
0answers
16 views

URL variable getting lost when using upload button on a managed file

I have a D7 form that I made using the form API. The URL to the form contains a URL variable like so www.mysite.com/myform?id=123456. (I know it would be better to do www.mysite.com/myform/123456, but ...
1
vote
0answers
35 views

Rename files on nodes

I have a content type called project, and also have a filefield there. I am supposed to allow users to rename the file. For this purpose, I've tried implementing hook_form_FORM_ID_alter and using ...
1
vote
0answers
27 views

Form always visible even when radiobutton value is changed (form api)

i'm having an issue with the property #states visible on a form. I want to hide it when form mercuriale's value is 1. $isMercuriale = db_query('SELECT isMercuriale FROM groupes_catalogues WHERE id = ...
0
votes
1answer
23 views

add a repeatable autopopulate node title select list to custom block

I'm going to develop a new block that user can select 4(or more) node with 4(or more) autopopulate node selection list but i couldn't find any documentation or tutorial on how to build those select ...
0
votes
1answer
28 views

Files in the file_managed table with status of 0, not deleting on cron

I have a form where I am uploading files to the "sites/default/files" directory. I am using the managed_file type in my form API definition. This is all working fine and I notice that in the ...
6
votes
3answers
206 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
17 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
2answers
39 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
2answers
48 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
24 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
19 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
30 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
20 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
36 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
33 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
31 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
24 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 ...
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
31 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
26 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
23 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 ...