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

Print out multiple upload fields on a page

I'm trying to output 4 upload fields on a page. But the problem is that it only outputs the first one and not the rest. All works fine when uploading the files with Drupal's form api, but I just can't ...
0
votes
0answers
12 views

TABLESELECT how to add two textfields in one cell?

How to add two textfields in one cell of table ? function fields_menu() { $items["fields"] = array( 'title' => 'test fields', 'page callback' => 'drupal_get_form', ...
0
votes
0answers
11 views

Entity creation-form: Prepopulate all existing entity-references of a field collection

I have a content-type seasonal_prices with field-collection containing an entity reference field (referencing content-type room) and a number field; the field-collection is multi-value with unlimited ...
0
votes
2answers
45 views

Re-use a form array multiple times

I'm a little stuck here. I want to make a block with 4 upload fields. So i'm trying to set the keys in 1 form array with the name file_link. When editing the block, I can see the 4 upload fields. But ...
0
votes
0answers
11 views

file_validate_size doesn't seem to work

I'm currently learning how to make a custom module that creates a block with a textfield and upload field. So far so good, only thing is: Drupal doesn't seem to respect my file_validate_size value. ...
0
votes
1answer
21 views

Add block to form (before submit button)

I'm having problems placing a block in my form. This is what I have now: I have a register form and a fb button block. I say the block must be visible only when page is equal to user register page. ...
0
votes
0answers
16 views

Can I apply more than one ajax callback to a field?

I have the following code in hook_form_alter() $form['field_sector']['und']['#ajax'] = array( 'event' => 'change', 'wrapper' => 'sub-sector-wrapper', 'callback' => ...
0
votes
2answers
45 views

Form submit handler not working

I'm developing a pretty basic module catalog_request that creates a form. I'm replacing the form's default submit button <input ..type="submit" /> with a <button ...>click</button> ...
1
vote
3answers
72 views
+50

Disable ordering in entity reference

I have an entity reference of widget type = autocomplete. It's a collection of users where you can add multiple users. Now I would like to disable the ordering of the users. So you can't order the ...
0
votes
0answers
6 views

Multiple Field , same ajax callback

I created a custom field. The hook_field_widget_form has an submit element with an ajax callback: //Add more $element['add_zone'] = array( '#type' => 'submit', '#name' => ...
0
votes
1answer
31 views

How to get attributes of the form elements?

I know that it should be easy, but currently it doesnt work. In my function I want to get #title of each element in the form. My form is fieldset "add_company". For example, when I try to get #title: ...
0
votes
3answers
41 views

Form: Custom submit callback is not called

I have a form with a second button which should add new form elements according to this page. The callback does not get called though. The second button is configured as follows: $form[ 'addTicket' ] ...
-3
votes
1answer
29 views

Add content form in a block

I want to add content form in a customized manner. For example consider Twitter is a custom content type i want a create a add new tweet button and display only the body field hiding the title and ...
0
votes
1answer
43 views

Form elements update and deletion in D7

I have made a form in D7 using form API,submitted values to that and retrieved entries from database;now what i want is to add a delete link in front of every retrieved row.My retrieval code is: ...
0
votes
1answer
20 views

My ajax Drupal form shows up old values

I have developed and AJAX Drupal add form (textfield and button) using #ajax key and callback function, where I do my process and return my form new element. So when I starts adding my data form, it ...
1
vote
2answers
21 views

add variable to process_page($vars) in form function

Is there an option to change $vars array in form function? I would like to pass some variables to page template in form creation function .. If not, what are other options to influence page.tpl from ...
2
votes
1answer
15 views

Modify how Drupal builds fields on a per form basis

I want to change the way Drupal builds specific fields on a specific node edit/add form on my site. For example, when I use print drupal_render($form['textarea']); in my ...
0
votes
2answers
18 views

AJAX error when ctools_modal_command_dismiss() is called

So I'm having a problem with dismissing a Ctools modal within a form submit's callback function. Once I have processed any submit data, I'd like to dismiss the modal without redirecting the page (easy ...
1
vote
1answer
175 views

User with uid=0 in database

I had to build a form with a select field populated with all the users registered in database. There are 10 users that I can see in admin>people. To get all the users, I used entity_load('user'). ...
1
vote
2answers
39 views

Submit handler doesn't work after theming the form

I have a form: function payment_system_coeff_form($form, &$form_state) { list($_SESSION['payment_systems'], $_SESSION['coefficients']) = payment_system_table(); $form['submit'] = array( ...
0
votes
1answer
32 views

Ajax field default value on edit form

I want ajax dependent fields in one of my node's form so I am altering the form. here is the code function mymodule_form_alter(&$form, &$form_state, $form_id) { $selected_first = ...
0
votes
0answers
23 views

Rebuild exterior elements of form on submit

On the user page I display two types of groups a user can be subscribed to: a pending membership or an approved membership. To illustrate this: The 'cancel membership request' button is the submit ...
1
vote
1answer
44 views

How to prevent drupal form's managed file upload ajax field from resetting the $form_state?

Edit: working code, although pretty ugly: if ( isset($form['submitted']['stelle']['#default_value']) && $form['submitted']['stelle']['#default_value'] !== '' ...
0
votes
0answers
24 views

html form and navigation

I am trying to figure out a way to add a html form that would allow me to call a external php program, I have issues with navigation, some how after clicking the submit button I am redirected to the ...
0
votes
0answers
18 views

Custom form adding a commerce price field

I am creating a custom form using the form api. I want to add a Price field from Drupal commerce to my form. Is it possible to add the Drupal commerce price field to a custom form. Updated Made it ...
0
votes
0answers
10 views

Program a pre-set value for a form block?

I have a simple custom module that creates a form block. We use this block to post content into a panel without the use of the PHP module. We wanted to know if it was possible for us to set a ...
1
vote
1answer
28 views

How to add class to individual radio item inside “radios”?

I need to style my radios as tabs. So I created a form element like this: $form['important_categories'] = array ( '#type' => 'radios', '#label' => NULL, '#attributes' => array ( ...
0
votes
0answers
9 views

Get the form elements dynamically for addressfield

I need to build address fields for a client, depending on the country. I wanted to use addressfield, since it has all the code to generate these forms for node edits. The code I'm using is: // get ...
1
vote
1answer
96 views

How to attach Dropzone.js uploads to a form element

I'm integrating dropzone.js into my form, but I have an issue regarding my file uploads. I have my dropzone set up, and file uploads are in the $_FILES array. I want to call file_save_upload to ...
0
votes
0answers
25 views

Saving body as HTML in custom content types

I have a custom content type that I want to save data to, the content type has custom fields and I used a secondary form that supplies the from data to be stored, when the user sees the view, the ...
0
votes
2answers
40 views

Attach js file to every page w/term reference widget in Drupal 8

I have begun trying to port a small, simple module that I maintain to Drupal 8. It was originally written (not by me) in Drupal 6 and used hook_init() in combination with drupal_add_js() to attach ...
0
votes
1answer
21 views

Setting #element_validate in a form (not form alter) removes original #element validation

I have an element with set #element_validate (in hook_element_info) and I use this element in a custom form. The problem is that when I try to add an additional #element_validate to the element in the ...
0
votes
1answer
14 views

user_profile_form doesn't show profile2 information

I'm trying to modify the user_profile_form, but it isn't working. My regular user edit information shows up, but not my profile2 information. function MY_MODULE_form_alter(&$form, ...
0
votes
0answers
23 views

Redirect to exernal url with posted data

I am using third party service (payment) which requires users to redirect to their payment page with posted ($_POST) data (this can be done by setting form action, very simple), but problem is - their ...
0
votes
1answer
30 views

Webform validation are working but they some error

when i am login or page redirect to home page they can show this notice " Notice: Undefined index: submitted in web_alter_form_validate() at line 19" here is my code function ...
1
vote
1answer
25 views

Issues with the entity field output

Suppose, we have an entity "song", that has a required field, called "authors": In the list of songs in the admin panel I want to output the list of all the authors in the search block: //search ...
1
vote
1answer
58 views

How to disable i18n language dropdown in node form?

I'ld like to prevent editors from changing the language of a node. Role check works. But I how to disable the language field? Why doesn't it work like any other form field? How is this field placed ...
0
votes
1answer
31 views

Add autoupload property after page load using plupload

In a form I have added a field for images, set the file source to "Advanced upload widget (Plupload)" ( all other checkboxes are unchecked ) and I get the interface. I want to make it autoupload ...
0
votes
0answers
15 views

Disable validation for certain part of a (highly nested) form

I have a rather complicated form for events & actions editing. It always includes one 'subform' for an event and N 'subforms' for actions. The #parents hierarchy looks like this (it's more ...
0
votes
2answers
46 views

Submit form when field value changed

I have a simple form with method GET as follow... function MYMODULE_form($form, &$form_state) { $form['#method'] = 'get'; $params = drupal_get_query_parameters(); $form['cat'] = array( ...
0
votes
0answers
25 views

Nested forms in Drupal 7

I have an ajax based multi step form with 5 steps. After the form has submitted I use drupal_goto to redirect the user to a thank you page. In the last step is a select list with payment options. I ...
0
votes
2answers
28 views

Set conditonal default value of a field

I have a custom form with a field... function mh_integration_connect_form($form, &$form_state) { $form['#method'] = 'get'; $params = drupal_get_query_parameters(); $form['cat'] = array( ...
0
votes
1answer
15 views

Creating a form with GET bypases the validation and submit

I am creating a simple form, when sumits, shows result from an external API. But URL remain the same, so you cant get a url if your search result and send it to someone. But when I use get ...
0
votes
0answers
11 views

How can I create a multi-column checkbox area for a specific page

I have a taxonomy term field in four of my content types that I am calling "methodological areas". It currently has quite a few items, 92 to be exact, which is a lot of items to display as checkboxes ...
0
votes
0answers
36 views

Upload image temporary and on form submit make it permanent

I have made a custom module where I load the create node form for an "announcement" content type. What i want Besides the text and select fields, I require an image field which supports multiple ...
0
votes
0answers
12 views

Deleting specific fieldset in custom API forms

I have a built a web form where one can add and remove fieldset. In my example, one can add more social links. I can also have a button that will remove the social link, BUT it will remove only the ...
0
votes
1answer
45 views

Issue implementing Ajax in form

I created a basic page which has a basic form and implements ajax, or attempts to do so. My issue is that it doesn't seem to be functioning as it should. What might be Ajax, only works after I press ...
0
votes
1answer
30 views

Get selected value and submit a form

I have a form, and I want to get the selected value of $form['dropdown_third'] and then use the value to create my table. What should I write in Submit function? function ...
0
votes
1answer
19 views

Custom field type with imagefield

I'm creating a widget with an image field. But I keep writing 0 to the database. But i need the fid to be saved. I know I can manipulate the data with hook_field_presave(). But the items array only ...
1
vote
2answers
65 views

How to add another field collection instances on Add Form page load programatically

I have one field collection with unlimited values in Commerce Product Add form. After performing some action, When user redirects to Add Product form, based on some predefined values in session, I ...