Tagged Questions
The form API is a very strong, robust, easy and scalable API for creating forms in Drupal.
0
votes
1answer
12 views
I am unable to get 'file' #type to appear in my form [on hold]
I am building a custom module where the user needs to upload an image. Here is the code for my form:
function floor_map_form($form, &$form_state) {
$form['file'] = array(
...
0
votes
0answers
11 views
Setting managed file default value from ajax request
I'm trying to create a form using the Form API with the following behavior:
For a custom slider module, users can choose to upload an image which is saved as a managed file. This works fine.
They ...
0
votes
0answers
15 views
Extra loading icon in Drupal form
I have created a custom form using (Drupal form API) , it has email field as autocomplete. For some reason there are two loading icon in the email field.
//implements hook_menu
function ...
0
votes
1answer
11 views
How to theme the Event content type node creation form in drupal 6?
I have installed Event module which gave me an "Event" content type.
I want to theme the node edit/creation form for the Event content type that automatically comes once the Event module is enabled.
...
2
votes
2answers
22 views
module's local *.tpl.php, defined in $theme_registry, “not found or invalid” when referenced later in module
I built a custom login module for my Drupal7.26 install.
Extending it, I've added a *.tpl.php locally
ls sites/all/modules/custom/jl_login/templates/
user-login-member-form.tpl.php
To get the ...
0
votes
1answer
24 views
How do I add tabledrag with 'weight' to admin form
I have built a fairly basic module but i'm struggling with the UX of the admin form. Essentially I need a list of items that have several values; a textfield, checkbox, select list and a button to ...
2
votes
1answer
59 views
Form hidden field doen't keeps its values
I'm creating a form with hidden field, I change the values of that field with jQuery:
function mymodule_form($form, &$form_state) {
$form = array();
if (empty($form_state[FIELDS_NUM])) {
...
0
votes
1answer
13 views
how to create a select field which holds the list of product properties and when i select from that the option is removed [on hold]
i am a newbies in drupal ,
i want to create a select field which holds the list of product properties and when i select from that the option is removed,
means when i creating a new content type then ...
0
votes
1answer
14 views
Removing field from form
I just came across a solution regarding media module.
It suggested that:
replace all
unset($form[$id]);
to
$form[$id] = array('#language' => NULL);
in media_gallery.module
This worked ...
2
votes
0answers
19 views
How to set form element order with field_attach_form (and why does it do it?)
Problem
I'm attaching the user register form to the add node form using hook_form_alter (for a custom content type). (Forcing an anonymous user to register when they create a node.)
My solution to ...
0
votes
0answers
16 views
Add more field set with ajax call
I'm using drupal 7, I read add more field example and I'm trying to do the following:
but in my case I want to add another fieldset with textbox, select and check box.
I did it with submit button ...
0
votes
2answers
23 views
change comment form container to textarea
How to remove the red section in next image (comment form)?
I have try change the type to textarea, but on submit the form a blank page appears.
function THEME_form_comment_form_alter(&$form, ...
0
votes
0answers
23 views
Webform skip page programmatically
I know how to hook_alter a Webform build form.
I also know how to validate it using a hook_validate.
Is there a chance to skip a certain Webform page when some validation code results in false?
I ...
0
votes
1answer
14 views
download file on form submission
I have created a form which has only a submit button. In the submit function I am generating csv file and saving it to the files folder using fputcsv function.
But Now I need extra functionality of ...
1
vote
1answer
16 views
check other commerce pane validation error
I am work on commerce pane, in hook_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order) I call a function to do something in pane sumbit,
something like
function ...
0
votes
0answers
44 views
What would cause a form validator with the right naming convention not to execute?
I am supporting a site that uses version 7.x-2.0-alpha of the File Entity module, and a user reported that updating files was not working.
Using a debugger and comparing to another site, I tracked ...
0
votes
3answers
163 views
+50
User being logged out of drupal when using form redirect
Looking at my logs I have an issue. I have not been able to recreate it myself.
I have a form which an anonymous user fills out. This form takes an email address. When submitting the form I take that ...
0
votes
1answer
34 views
Form submit to page with another Form
I am trying to make a submission from one page that has a form to another dynamic page with a form. As you can see in my hook menu I'm using drupal_get_form as the callback and I would think this ...
3
votes
1answer
41 views
Complex form - merge of two with single callback
I have a complex form of two logical parts, which I have placed in different functions (my_module_partner_form & my_module_fields_form). Both forms have submit handlers (my_module_partner_form - ...
1
vote
3answers
39 views
How to add an image field to a programmatically created form?
Basically I want to create a block with my module which's edit page has a few content fields and two image upload fields. When visiting the node where this block is rendered, I want to render the ...
0
votes
1answer
17 views
Can I skip or bypass translation when creating a form #options elements?
I know I must use t() function in Drupal, but my particular task involves a great number of values in Russian, for which I do not want to enter values as
t('Moscow')
and then manually translate ...
1
vote
1answer
33 views
Why can't I set radios default value (when after build is done)
I'm putting a node add form on a custom page that is a menu local task tab for specific taxonomy terms, and trying to set default values for some of the elements.
I'm building the form like this:
...
0
votes
0answers
37 views
Dynamic form - remove button
I just saw this tutorial that generates a dynamic form of 3 fields (first name, last name and birth date), displayed each in fieldset.
In that tutorial there is only button for removing last field ...
0
votes
2answers
59 views
How can i remove required field validation on click submit button?
I have some radio buttons such as draft, need review, etc. I want to remove (omit) the required fields when draft is selected, and click on the submission button.
I tried with below code but it is not ...
0
votes
0answers
8 views
Why does DrupalWebTestCase (SimpleTest) encode multiple select options with indices?
Summary: I've written a module that uses the Form API. When multiple form select options are POSTed using my web browser, they get encoded (by the browser) like this:
option[]=Value A
option[]=Value ...
0
votes
2answers
30 views
Redirecting after submitting content - why this code doesn't work?
function MYMODULE_form_alter($form, &$form_state, $form_id) {
if($form_id == "zdjecie_do_projektu_node_form" ||
$form_id == "zdjecie_ze_szkolenia_node_form" ||
$form_id == ...
0
votes
1answer
16 views
Attaching a system js library using #attached property (D7)
When defining a form using the form api I can attach my own css and js like this:
$form['#attached']['css'] = array(
drupal_get_path('module', 'my_module') . '/my_css_file.css',
);
...
0
votes
1answer
43 views
Custom form callback
I created a custom theme.
function test_module_menu() {
$items['my-test'] = array(
'title' => 'My title',
'page callback' => 'test_module_page', /* callback function */
...
1
vote
1answer
17 views
How to make #cols work in drupal textarea
According to the Form API, you control the number of columns in a textarea with the #cols attribute. However, setting this seems to have no effect when I use it inside a $form array (the companion ...
0
votes
1answer
20 views
Hot to pass an argument to #ajax['path']
I have a form with a radio buttons (inside div#edit-field-nomination-und). I need to call a following AJAX callback:
function _onfit_ajax_get_term_description_callback($term) {
return array(
...
0
votes
1answer
67 views
AJAX: Form API Dependent Drop Down with more options
Started with the example here:
https://api.drupal.org/api/examples/ajax_example!ajax_example.module/function/ajax_example_dependent_dropdown/7
However, I then wanted to add a third option that was ...
-1
votes
0answers
14 views
Form always makes a callback to server on each form element entry
I have a form that I have created programmatically. It consists of all types for form elements (textfields, text areas, selects and what not). The issue I am having is that everytime a user enters a ...
0
votes
1answer
17 views
Create a form without creating a page
It seems simple enough to create a form in Drupal 7 with the Form API, however, everything I find shows that you have to use hook_menu() to add a page and then generate the form that way.
I would ...
1
vote
1answer
42 views
How to use drupal_get_form outside of a menu
I am trying to use the drupal_get_form funtion outside of a menu and am not having any luck finding examples of how this is done.
An overview of what I am trying to achieve is:
1) Pass control from ...
0
votes
0answers
9 views
How to create confirm mesage popup when register?
I want to show user data when user click to create account in registration page. I'm a new for drupal 7. anyone can guide ?
thank you
0
votes
0answers
42 views
Difference between hook_form_alter and hook_field_attach_form
I was attempting to add default values to the addressfield field type (on the Drupal Commerce billing pane), and originally tried doing this in hook_form_alter and it did not work. I then found the ...
0
votes
1answer
32 views
Form posting before ajax can update content
My form is submitting faster than ajax can update my textarea. How can I delay the form from submitting so the ajax can update my textarea?
$form['submit']['#ajax'] = array(
'callback' => ...
0
votes
1answer
29 views
Drupal 7 ajax callback function has to be defined in the same file?
I have defined a textfield that includes an ajax callback in file. In another separate file I have the ajax callback function defined. Will this work or does the callback function need to appear in ...
0
votes
1answer
93 views
How do I re-attach AJAX behaviours to a managed_file field?
I currently have a form which is generated by the FAPI via an jQuery AJAX call, and then is inserted into the DOM.
This works fine, but the problem is that managed_file field within the newly ...
1
vote
0answers
46 views
How to properly duplicate image for “clone” form? [duplicate]
I have a form for cloning entries. Basically it works the same way as entry add form, it saves under brand new ID, but is pre-filled with data from existing entry.
For data like text and references, ...
0
votes
0answers
20 views
How to grab a key value for password request form input?
module: form block, i create .tpl file for password request block. But i have small problem: printing elements value doesnt work in this template and i dont get a key value.
What i must do, to grab it ...
0
votes
1answer
22 views
Drupal 7 - Module with form and view
I'm trying to develop a module that creates a form and a view that displays that page.
In my module I used hook_menu() and hook_form().
Also I saw some tutorials 1 & 2
What I cannot understand ...
0
votes
0answers
49 views
How to programmatically create an entity-reference when submitting a form?
I'm working with the entity reference module. I have two node types (Type A) and (Type B). The basic concept is to let users reference multiple nodes (type a) into another node (type b).
So I ...
0
votes
1answer
30 views
How to pass a value from form(block) to the page and show this page?
I created a block with a form (elemnts: textfield and submit). Also have a page created by the hook_menu. I want that when you click on submit in block, the value from textfield transmitted to a page ...
1
vote
0answers
26 views
Javascript not loaded in loading ctools modal
I have a some modal forms, the link of those embedded in views result,
link are somethings linke share/nojs/2 , I register a menu in callback of the links,
It work correctly for root user, but I ...
0
votes
1answer
31 views
How do I add reCaptcha to a custom form?
I need to add a reCaptcha to my form; creating the form then adding the form ID to the reCaptcha settings did nothing.
0
votes
0answers
9 views
Render Intermediate form results in multi-page form through Webform module
I am using webform module and wonder how can I display intermediate form results in a multi-page form after each pagebreak in the form. I found tutorials on how I can display end results of the form, ...
3
votes
1answer
59 views
prevent submit in ajax call
I have a form with 2 submit in it, one of them is a button to generate codes, everytimes I click on generate form_submited called up and a record insert in db, how can I prevent form_sumit in ajax ...
1
vote
1answer
40 views
Drupal Forms API how to get degree sign onto submit button
I'd like to have a submit button with "°C" value on it. But when I just copy paste the degree sign, I get an empty value. When I try HTML code for degree sign (°) it is escaped so I get ...
0
votes
1answer
25 views
Why AJAX does not change field's value?
I wrote simple code:
function rah_cc_generate_form($form,$form_state){
$form=array();
$form['gen']=array(
'#type' => 'fieldset',
'#name' =>t('generate gift card code'),
...