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
2 views

Managed_file images disappearing after form resubmission

I'm building a site using the Nexus theme, and wanted to give users the ability to change the slideshow images using Drupal rather than using the default FTP (which is an odd way to make people update ...
0
votes
0answers
6 views

filter_xss() stripping out specified $allowed_tags (Drupal 7)

I'm busy building my first ever module, and I've hit a bit of a snag. On my form, I allow the user to input some SVG image markup/code. I then use AJAX to load this input into a wrapper DIV below it ...
0
votes
1answer
12 views

How to correctly get Form API single checkbox value variable from database?

I created an additional_settings fieldset for node type forms that holds a single checkbox: $form['MY_SETTING']['enabled'] = array( '#type' => 'checkbox', '#title' => t('Enable'), ...
0
votes
1answer
17 views

Add prefix to the error message

How I can add some prefix to the all error messages? Example: This field is required! and I need Error: This field is required! I'm using Clientside Validation module for error messages in my ...
0
votes
1answer
23 views

Display date picker not inline in Drupal 7 Forms API

I have installed Date Picker Module and it works fine. Below is the code: $form['date'] = array( '#title' => t('Select your birthdate'), '#type' => 'datepicker', '#date_format' ...
0
votes
1answer
26 views

Unexpected Entity Reference Autocomplete behaviour

I'm using Entity API, Form API and Entity Reference Autocomplete in Drupal. I have a relationship between two types, clubs and courses, each club can have many courses so basically the table course ...
0
votes
1answer
28 views

Sending data via post and redirecting user

So I made a module that needs to gather some data and redirect user and that data to a payment site. function payment_upload_form($form, &$form_state){ $form = array(); $form['#action'] = ...
0
votes
1answer
14 views

How to add a confirmation form upon submission of user profile form

I have previously added a confirmation dialog to my own forms using a technique like http://blog.purdy.info/2014/04/how-to-work-with-confirmform-in-drupal-7.html. However this assumes that you have ...
0
votes
0answers
28 views

Checkboxes values

I have a column of checkboxes (not checkbox), what I want is to get : value = 1 (when one of them is checked, 0 if not), what I have now : if one checkbox of them is checked it returns the "name" of ...
0
votes
0answers
14 views

How to get human readable name of the item which gets selected in form? [duplicate]

When I select options from select list, machine name is rendered. I want it to render human name instead and all operations obviously will be performed with the help of machine name. How can I force ...
0
votes
1answer
14 views

How do I get the password from form API to use to log into external site?

I have these functions, one is for the Form API and the other, git pull, is called on a cron hook. The password is coming up blank and therefore the git pull is not working. function ...
1
vote
1answer
24 views

How can i set the width of the select box in drupal form

Currently i have a select box in a form as follows : $form['fieldset']['event_trigger'] = array('#type' => 'select', '#title' => t('E-mail event trigger'), //'#default_value' => ...
1
vote
1answer
24 views

Drupal 7 Form API file field - not recognizing the imported file

function test_data_import_form($form, &$form_state) { $form = array(); //$form['#attributes'] = array('enctype' => 'multipart/form-data'); $form['import_data'] = array( ...
0
votes
2answers
20 views

How to redirect form to a url having wild card character in drupal?

How to redirect form to a url having wild card character in drupal? For example, can I do like this below shown? $form_state['redirect'] = 'admin/component/%/edit' or any other alternative approach ...
-1
votes
1answer
21 views

How to generate a **uid** whenever a form is submitted, and want to pass it in every form I made to update specific user results

I have created a form with the menu item url like this. $items['/component'] = array( 'title' => 'Component', 'page callback' => 'drupal_get_form', .... ); my form structure is ...
0
votes
2answers
32 views

js file run again when file upload ajaxly

I have a js file that I add it to my form in hook_form_alter with drupal_add_js, in my js I set a click handler on Html object(lets name it ".myhtml" ), everything work correctly in first load. I have ...
0
votes
0answers
20 views

Displaying fields and populating value from database in textfield using ajax.

I am having one search form. In which I took three fields, Month, Year and Email address accordingly. 1. I want one text box field and submit button on condition like if all those three are field. ...
0
votes
0answers
24 views

How to set checkboxes on a tableselect

I want to display tableselect with a column with only checkboxes this is my code : function liste_sections($form, &$form_state){ $form = array(); $form['checkbox'] = array( '#type' => ...
0
votes
1answer
25 views

How can i load options in to a select box when creating form element

I am creating form using drupal_get_form and i using the following code for creating a select box $form['select-user-group'] = array( '#type' => 'select', '#title' => t('Select a ...
0
votes
0answers
29 views

D7 db_update — how do I get the unique ID (primary key)

I am working on an edit/update function in my module. I am able to populate the form with the correct data based on the unique ID but am unable to pass this to my submit_handler function. Submit in ...
0
votes
0answers
14 views

Programmatically set a multi value date field

$checked = array(); foreach($form['field_rundays'][LANGUAGE_NONE]['#default_value'] as $key => $val) { $checked[$key] = $val; } r($i=0;$i<count($checked);$i++){ $date = ...
0
votes
1answer
14 views

Forms API TableSelect with Drag&Drop Weight

I'm using Drupal 7 form api. I have a tableselect and have been looking all over the internet for a tutorial for how to make a tableselect have sorting/click&drag functionality. I have found ...
0
votes
1answer
31 views

How to call form function in menu callback in drupal7?

I have one menu and two functions that want to call on same menu. What I am doing is, in hook_menu page callback i am calling a function and in that function i am calling another function.Means, ...
0
votes
0answers
34 views

Ajax on submit button not working second time

i am using ajax on my custom module (via example module) the issue is ajax dependable select menu working correctly and the submit button also giving result properly but submit button becomes not ...
1
vote
2answers
16 views

How do I allow access to my custom module to “anonymous user”

case : I have created a custom module Implemented a hook_menu() as shown function my_custom_menu() { $items = array(); $items['my/custom/link'] = array( 'title' => t('My Custom ...
0
votes
0answers
29 views

Tableselect with only checkboxes in every line

As said in the title, I want to create a table made of a list of "persons" (the left column) and few columns in order to only check properties of every person, that why I need only checkboxes on this ...
0
votes
1answer
23 views

Delete/Edit selected record from rendered tabular form results

I have made a form and retrive form submissions into a tabular format. I put 2 links ahead every single submission - Edit/Delete Now, when I click "edit", its corresponding edit form should open. ...
0
votes
0answers
13 views

Form API: Populate tableselect options with AJAX

I want to add a series of sections to the node create/edit form I have for a custom content type. They all work in a similar fashion, in that I pull data from another database and display it for the ...
0
votes
1answer
25 views

login user after form submit

I have a form that one of fields is mail field, when form submit I check that email if not belongs to any user I create a user and assign that node to the created user, Then I want logged in that ...
0
votes
1answer
52 views

Get the value of a form element returned from an ajax callback function

I have a select element and submit button in my form : $form = array(); $form['myid_template'] = array( '#type' => 'fieldset', '#title' => t('Select Template'), '#suffix' => ...
0
votes
1answer
41 views

Custom validate function not working

I'm sure there's some simple reason that my custom validate function isn't executing. Here's my code: function MYMODULE_form_message_ui_instance_message_manage_alter(&$form, &$form_state, ...
0
votes
1answer
36 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
11 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
14 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
21 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
48 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
1answer
62 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
20 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
36 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
3answers
41 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
15 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
14 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
21 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
23 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
37 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
19 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
21 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
1answer
31 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
8 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
59 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. ...