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

Stripe_InvalidRequestError: You cannot use a Stripe token more than once

I'm trying to integrate Stripe’s Checkout and PHP into a simple module and I've got the following: Stripe::setApiKey($stripe['secret_key']); if (!empty($form_state['input'])) { $input = ...
0
votes
1answer
12 views

tabs not showing

I know this question have been answered many times but i realy do not know what i'm doing wrong. I want a config page of my module with 2 tabs in it. But it won't show a thing. here is the ...
0
votes
1answer
15 views

How to find the name of changed file in Forms API

I've a file field attached to a node form. I want to know in the submit handler if the file has been replaced then I'll take some action. For example I delete the previously uploaded file : abc.txt ...
0
votes
0answers
11 views

Custom theme for form checkboxes causes AJAX behaviors to not attach

I have the following code implemented to override the theming for the checkboxes in a Drupal form. //themes neighborhood checkboxes with AJAX link wrapper function ...
0
votes
1answer
21 views

I want to show a progress bar during form is submitted and processed until submission is created

I am using Form API to create a form on a page and I ask user to submit CSV File which is then process in _submit function for that form. Kindly suggest me a way to add progress bar with Drupal's way. ...
0
votes
0answers
15 views

Textfield values not being stored on form submit

Ok, so I'm working in Drupal 7 and am making a form that either inserts values in the database or updates existing information in the database. Each row of my table has two entries, 'counter_name' ...
1
vote
0answers
15 views

How to check if a form is being rebuild?

I want to perform a function if the form is being rebuild. i.e. If validation fails, or Form is rebuild for any other purpose. I do not want the function to run in any other case. How can I do ...
0
votes
1answer
20 views

Access page variables in form template

I have a customised form template 'user-profile-edit.tpl.php' and i'm trying to add some custom variables so I can get a block of dynamic content (users current friends / requests etc) to display in ...
-2
votes
0answers
31 views

foreach form element doesn't work [on hold]

i have this hook_form_alter $tassonomia = taxonomy_vocabulary_get_names(); foreach($tassonomia as $rec){ $vid = $rec->vid; $array_val = array('0' => '--none--'); $tree = ...
0
votes
0answers
14 views

field_attach_form: multi-image is not working on ajax

I am using custom form and in a fieldset I am assigning field which is from content type I get by using field_attach form. When I attach it directly it is working fine. But when I use it attaching to ...
2
votes
1answer
23 views

how can I set #attributes for each item of selectlist

I know I can set style for form items with #attributes but I want set background for select list (drop down) items, how can set #attributes for each item of select list(dropdown) in form_alter ?
1
vote
1answer
18 views

Is there a way to add clauses like accept = 'image/*' to input items via forms API?

I'd like to add "accept" attributes to some of the input fields for my site's content types -- to end up with something like <input type="file" id="edit-field-whatever-und-0-upload" ...
0
votes
0answers
22 views

How to make ajax call in jquery in custom module form api drupal 7?

Background: I am using module manualcrop within custom module using form api, where user upload image ( with managed_file type ) and can crop it and save the form. I want to show a preview as soon as ...
0
votes
1answer
19 views

Custom Form API elements in node form

I am rendering node form on my custom page with such a code: <?php $form_state['build_info']['args'] = array($node); form_load_include($form_state, 'inc', 'node', 'node.pages'); $form = ...
2
votes
1answer
24 views

How to limit number of files uploaded with plupload integrtion module?

I'm using Plupload integration module. In my Form API form I want to use it as simple replacement for file element. However, both file and managed_file types accept one file. plupload accepts any ...
0
votes
1answer
21 views

How to retrieve sumbitted data in modal

I want in add content have a link(or button) when user click on lt the popup (modal or any popuping method like dialog,modal,lightbox,colorbox ) will open, in that form I want have some field, like ...
0
votes
0answers
25 views

ckeditor not loading on element generated via ajax call?

I am using custom form and generating form elements with ajax call but textformat is not loaded with ckeditor. Here is my code: function form_callback($form, $form_state){ $form['features'] = ...
1
vote
1answer
28 views

how can i attach a taxonomy to the users profile?

I use drupal 7 and need to attach a certain taxonomy to a user. there is module for drupal 6 but as i see there is no module for that in drupal 7. how can i do that in my module by coding? why do i ...
0
votes
2answers
71 views

How to reload page after ajax form submit

I'm using FAPI #ajax to make the form more user friendly (it reloads in-place on validation). Works like a charm. However I would like to reload the page after form is submitted. How to that? ...
0
votes
0answers
33 views

Entity reference - hide some references in multiple-reference field edit widget

I have a node (group) with an entity reference field that is used to link it to other nodes (stations). The relationship between them is 1:N (one group : many stations). The problem is that I need to ...
0
votes
0answers
21 views

Form API: completely custom tableselect?

I need a table that'll have some rows tableselect and some not, also it I should be able to set properties on specific rows and cells, not just inputs. Row can have 1 or many values. Is that possible ...
1
vote
1answer
25 views

Keep custom theme when using AJAX submit

I am using the following code to switch to a custom theme based on the URL function job_agent_custom_theme() { if (arg(0) == 'vista') { return 'vista'; } } This works great and will switch ...
0
votes
1answer
31 views

How to disable Rich Text Editor in image field caption ?

I am using Image Field Caption module. It provide a image caption field but I don't want any rich text editor appearing for the caption field. How to disable that for any specific field?
0
votes
1answer
31 views

Submit to external url via Ajax & get return

I need a Drupal form to submit a file to an external server using ajax. I have done the form using Form API and I am able to submit it via Ajax, But the Drupal throbber never stops and I am not able ...
0
votes
0answers
19 views

Let users add related content on frontend

I need to allow frontend users to add entity references to existing related content similar to what Inline Entity Form module does on the backend. I know, that I could probably use Panels module to ...
-1
votes
1answer
71 views

node add save in ctools modal fails

I'm writing a module to get a simple node add form into a ctools modal dialog. I get the form into the modal ok, but when I click save I get this ajax error An AJAX HTTP error occurred. HTTP Result ...
0
votes
0answers
16 views

How to reuse the same str_replace-like function pathauto is configured to? [duplicate]

Use case: Custom module to alter CONTENTTYPE_node_forms to hide some of many entity reference options when adding/editing a node. Then via a custom validate I set ...
2
votes
1answer
74 views

When using hook_form_alter to modify a content type's node add / edit form, where do I put the #states property?

This is actually a compound question. All in all the question is: When using hook_form_alter to modify an existing content type's node add / edit form, where do I put the #states property, and, ...
1
vote
2answers
20 views

How can I add form elements in custom form on click of link?

I want to add form elements inside my custom form when some body clicks on the link outside the form. Links are like : Add textfield Add selectlist When user click on any link it via ajax add an ...
3
votes
3answers
63 views

How can I gracefully interrupt an AJAX callback?

I have a form element that triggers an AJAX callback call when it looses focus. This callback can take a few seconds, which generally is not an issue. If a user submits the form before the AJAX ...
2
votes
1answer
37 views

How do I use the form hook alt to edit fields of inline entity form?

I am trying to use the hook_form_alter to modify the fields of an Inline entity form in a commerce product display node. I know how to edit a normal field but this does not work for an entity form ...
0
votes
1answer
9 views

AJAX link error (form API)

I have an AJAX link and a callback function. The problem is that when I click the link an error is thrown. I have absolutely no idea where did I make an error, the debug information unfortunately ...
0
votes
0answers
36 views

Drupal 7 “The form has become outdated. Copy any unsaved work in the form below and then reload this page.”

I have a problem. When I put this code in my module checkboxes work great but form throws an error: "The form has become outdated. Copy any unsaved work in the form below and then reload this page." ...
0
votes
0answers
15 views

Styling Forms in Drupal 7 with Twitter Bootstrap [duplicate]

Being a complete Drupal noob i'm lost in a vast amount of conflicting information in my searches. I'm finally getting to the polishing part of my website, I'm wanting to stat styling my forms like I ...
0
votes
1answer
32 views

Retrieve File Url from Upload Form When Form is submitted

I have the following code in my form. function video_subtitles_menu() { //print "video_subtitles_menu 1";exit; $items = array(); $items['video_subtitles_test/upload'] = array( //this creates ...
0
votes
1answer
20 views

Ajax ignoring my default_value

I have a drupal form that contains a select box. Next to the select box is a link that pops a ctools modal up with an inner form that adds a value to the database table that drives the original select ...
1
vote
2answers
63 views

how should i send data form my custom module to a php file after submitting?

I have a Drupal form like this: function myblock_menu() { $items = array(); $items['my_module/form'] = array( 'page callback' => 'my_module_form', 'access arguments' => ...
-2
votes
3answers
34 views

insert checkboxes in data base

I want to insert a checkboxes in database ,I do not guess how it works <?php /** * * Implements hook_permissions. */ function demande_permission(){ return array( 'submit_demande' ...
0
votes
1answer
25 views

Value from ajaxified form field not passed to ajax callback

This is a continuation of this issue, where I couldn't get the ajax to fire on an entity reference field in a node edit form. With the following code, I'm able to get the ajax to fire. /** * ...
1
vote
1answer
47 views

Rebuild form AFTER ajax callback has run

I have a form with a button that when pressed re-builds a different part of the form via an ajax request. Upon clicking the button the form is rebuilt, then my ajax callback is called which saves the ...
-1
votes
2answers
82 views

Combine two functions [on hold]

How can I combine two functions? Now I get the error: Cannot redeclare xxx_form(). As example: function node_example_form($node, $form_state) { return node_content_form($node, $form_state); } ...
2
votes
1answer
49 views

D7 form field #ajax callback not called on autocomplete field

I have an entity reference field, and I'd like to do some ajax so that when a value is selected for that field, some text is displayed in a div below the field. Since it's on a node edit form, I'm ...
1
vote
2answers
61 views

How to create similar to multi-image field struture in drupal using form api

How can I make a structure like adding new textfield with a button and removing that field with remove button. The structure generated should be similar to when we upload a image in multi-image field ...
0
votes
1answer
31 views

How to group fields in the form without grouping them in the node view? [closed]

My issue is that using the field_group module will create field groups for the form and the node view. And I don't want to group fields for viewing, I just want to make the form neater. Here's a ...
0
votes
0answers
10 views

Redirecting a Views exposed form

I have a node view 'resources' with exposed filters in a block. I'm trying to add a submit handler configured to set $form_state['redirect'] to apply an argument. My code checks out, but the ...
0
votes
1answer
27 views

Change the file field description

How can i change the file field description without hacking a contrib module like the file.field.inc file ? this is the function i would like to modify: theme_file_upload_help
1
vote
1answer
24 views

FAPI initial checked state for #type => radio

Drupal FAPI reference doesn't have a working example for #type=>radio. How can I indicate that I want the element to be rendered in a checked state? $form['my_radio_button'] = array( '#type' => ...
1
vote
0answers
16 views

I can't get the og_group_ref set in a node form rendered via a custom block

My block code is as follows: mymodule_block_info() { $blocks = array(); $blocks['my_contenttype_form_block'] = array( 'info' => t('My CustomContentType Add Form'), 'cache' => ...
0
votes
0answers
17 views

Dynamic list of select field

I have created list field for content type. My allowed values list is huge and dynamic. Is there any way i can use this field and dynamically create allowed values list, without saving all options in ...
0
votes
1answer
28 views

Programmatically load and submit the user form

I want to programmatically load the user profile form for a particular user and re-submit it without changing any of the existing values. The reasons are complex but I am dependent on gathering data ...