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

Add Brightcove field through form in custom module [duplicate]

I'm using Brightcove Video Connect 7.x-6.0-beta2 module and I want to add field in my custom module. I was tried with brightcove, brightcove_video and brightcove_field types and it is not working. ...
1
vote
2answers
13 views

How to hide fieldgroup Items in form alter

I know how I can hide any field in hook_form_alter,but I want to hide all items of field group in hook_form_alter I try function modname_form_alter(&$form, $form_state, $form_id) { switch ...
0
votes
1answer
23 views

Extra checkbox in tableselect rows

I have a list form in a module, which is giving me three columns, the first of which is a checkbox column. function popups_list_form($form, &$form_state){ global $base_url; ...
0
votes
0answers
10 views

Cannot display image thumbnail when uploading photo

I am doing everything by examples, but can't display my custom theme for displaying thumbnail when uploading images: function act_profile_page() { $form = ...
0
votes
1answer
19 views

How to set query result on a text field?

I want to show a result of a select query (with row count) in a text field after submiting. Here is my code : $form['my_textfield'] = array( '#type' => 'textfield', '#title' => ...
0
votes
0answers
14 views

Conditional Fields Based on an element in a fieldset using states

I have a select form element: $form['myid_template'] = array( '#type' => 'fieldset', '#title' => t('Select Template'), ); $form['myid_template']['template_options'] = array( ...
1
vote
2answers
26 views

What is the good way to pass a value from form creation function to its submit handler?

I am newbie in Drupal, I have a query that i want to pass some value from form creation function to its submit handler. Right now, I am saving that value in a form element of hidden type. ...
0
votes
0answers
7 views

Multilingual field in form_alter

I have a form_alter that needs to act upon multilingual fields. In order to have the fields load with proper language I do this at top of the form_alter: global $language; But then, in the fields ...
2
votes
1answer
59 views

How to get the default value of radio button from database?

I have 5 check-box. For each check-box, 5 radio buttons get generated. These radios value get saved to database. Now what I want is, when I select check-box, and if the selected check-box has some ...
0
votes
1answer
26 views

Drupal form disable form error message or use ajax validate instead of #require

I have a complex form. Which will let users to select some drop-down items to add a food diary record. Currently, I'm using this if (!form_get_errors()) {.....} to decide whether to insert new ...
1
vote
2answers
67 views

PHP require_once() warning with hook_menu

I'm writing a small module for learning purpose, where I try to create a module settings form using hook_menu() and form_api. Everything look good in my code but I still getting this error message : ...
0
votes
0answers
23 views

How to insert option text in database instead of index key for a form input element

I'm inserting checkbox value, radio value and dropdown value in database. At the time of inserting the data in database the index value of them are stored but I want to store text value of them. For ...
0
votes
0answers
12 views

How to force form_state['input'] to form_state['values']

I have a custom form that uses AJAX to add new fieldsets internal users can specify a default set of artists, e.g. 4, and send this to a record label/management etc. the rep can come to the form, ...
1
vote
0answers
20 views

How to validate link field using link module validation in custom form [on hold]

I'm using the link module. I've created custom form with a link field. How can I validate this URL in my custom form? Should I use links helper function to check if link is valid (e.g. ...
0
votes
1answer
36 views

How do I keep unique form id for ajaxified form?

I have a form(which is extending the FormBase class) that requires entity as argument(but I am not manipulating with this entity so that's why I am not using the EntityForm which is irrelevant to this ...
1
vote
1answer
36 views

FormAPI cannot get checkboxes return value from AJAX call via external database query

I have not been able to get the return #options value when using AJAX for a dependent checkbox after selecting a value from select. My AJAX isn't great, and I've searched all over, I'm hoping someone ...
2
votes
0answers
39 views

How to tell if user selected an autocomplete option in a form?

I created a form that has an autocomplete field of registered users and it is attached to nodes. In the form validation function I check if the string of the textfield is a valid user but in order to ...
0
votes
2answers
39 views

How to make a specific button invisible with hook_form_alter? [on hold]

Can someone send me the code to make the button with the following source code be invisible using hook_form_alter ? <input type="submit" id="edit-publish" name="op" value="Unpublish" ...
0
votes
1answer
28 views

How to reload Google chart on ajax submit?

I have a simple Drupal form. I am using hook_theme() to draw a chart right under my form. I am using Google chart API. When the page loads first time, my chart appears with no problems. But when I ...
1
vote
1answer
52 views

Select option in Drupal form API

I've created a drupal custom form. I've used a select option for bank which get its value from the bank table. I want to store bankID in bankbranch table and which is a foreign key and display bank ...
0
votes
1answer
33 views

How to set attribute for checkbox field

I want to add the attribute data-toggle="toggle" to a checkbox field. I thought I could use the hook theme_checkbox which is: function theme_checkbox($variables) { $element = $variables ...
2
votes
3answers
58 views

Add javascript to a content type form in Drupal 7 [duplicate]

I'm trying to add a custom javascript file to my article content type forms (add/edit). I've tried mythemename_preprocess_page, hook_form_alter and theme_content_type_node_form to no avail. They ...
0
votes
1answer
33 views

How to call AJAX on check-box of form API?

I need to get radio buttons in a form, whenever a checkbox gets enabled/clicked. Say, I have 5 items listed in a checkbox, named orange, apple, .....When I enable orange checkbox, a set of radio ...
0
votes
1answer
25 views

My form validate function will not run.

I am using Organic Groups. That module has a form where you add new members to a group. I would like to run additional validation on that form. I use hook_form_alter and can identify the form. I add a ...
1
vote
1answer
20 views

Drupal 7: Is there any way to add a filefield for multiple upload file to a custom form?

I'd like to add a file upload widget to a custom form, with core file module, as shown in the admin edit node page. I've trying with the 'managed_file' API, but I've only got upload one file. I need ...
1
vote
0answers
32 views

Form API multiplie file upload validation error

I have a simple form with a multiple file upload field. I am trying to validate the documents against extensions and file size. The validation seems to work, but now if I don't select any file (field ...
0
votes
1answer
47 views

Drupal 7 Query database and display results same page in custom module template

I want to see the results on the same scree after submit. But my results php error "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in ...
0
votes
1answer
19 views

Table Pager Rendered in an Ajax Callback Shows White Page

I have the callback function below that renders a table with a pager. Every page of the table is 20 rows. Below is the code: function myid_print_all_submitted_id_callback($form, &$form_state){ ...
1
vote
1answer
24 views

Book outline in custom form

I am creating a custom form which creates new nodes of type 'book'. I have been able to get the "book outline" to render on my form using $nid = $node->nid ='nid'; module_load_include('inc', ...
0
votes
2answers
43 views

Collapsible fieldsets in form using button

How can I make a button collapse a fieldset in my custom form? I tried the following which did not seem to work: $form['stepone']['next'] = array( '#type' => 'button', '#value' => ...
0
votes
0answers
26 views

How to display image preview right away for managed_file form element?

I have managed_file for uploading an image in my form and I would like to display the image(thumbnail) right away when the user uploads it so he won' have to submit the form to see it(I am rendering ...
1
vote
1answer
27 views

Ajaxly set Text Field Value with Drupal Forms API

I have a text field and a ajaxified link in my form: $form['id_number'] = array( '#title' => t('ID Number'), '#type' => 'textfield', //textfield '#suffix' => ...
0
votes
1answer
35 views

access $node in form breaks ajax call

I built a custom form that works well, however I updated my custom module to create a custom content type and add the form via hook_node_view(). Everything works, until I access the $node object in ...
0
votes
2answers
24 views

How to render a static html from a drupal module

I need to call a static html page and display the content of it when calling it from the module function , i tried to call from the form api but its just rendering the full markup ,please help here ...
0
votes
0answers
21 views

Fatal error: Call to a member function extractFormValues() : Drupal 8 beta 14

I created a module with Drupal 8 beta11 which defines an content entity and a form (contentEntityForm) with custom submit callback.When I tried using the same module with Drupal 8 beta 14 it raise the ...
0
votes
1answer
42 views

How to give confirmation for deletion through link?

I have tabular format data and each row I have an edit and delete links , on clicking on the delete link it should ask for a confirmation to delete and if press delete only I need to delete. Now its ...
0
votes
0answers
25 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
7 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
16 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
23 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
38 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
37 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
36 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
31 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
33 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
27 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
25 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 ...