The form API is a very strong, robust, easy and scalable API for creating forms in Drupal.

learn more… | top users | synonyms (1)

1
vote
1answer
29 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
1answer
23 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
15 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
9 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
27 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
6 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
36 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
22 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
31 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
15 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
10 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
15 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
29 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
22 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
55 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
18 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
41 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
15 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
9 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
30 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
10 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
44 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
17 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 ...
0
votes
1answer
52 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 ...
1
vote
1answer
22 views

Alter taxonomy autocomplete value

I need to alter the element value of a taxonomy autocomplete field before it is processed and can't seem to find a way of doing so. taxonomy autocomplete fields have an element validator attached, ...
0
votes
1answer
14 views

Can't set default value with hook_field_widget_form_alter()

function mymodule_field_widget_form_alter(&$element, &$form_state, $context){ if ($context['field']['type'] == 'node_reference' && empty($element['#default_value'])) { ...
0
votes
1answer
12 views

Update Webform and not Add if there is an existing value in one of the fields

In Drupal 7, I have a field which stores Usernames of the user. If a submission is made by a user, it stores its username. All I want is that if there's an existing submissions made by a user, and ...
0
votes
2answers
87 views

When should one use #value_callback and when #element_validate?

I've tried to get into custom element creation but ran into problems with #value_callback and when #element_validate, more specifically their lack of documentation. Imagine you have a custom element ...
0
votes
1answer
10 views

Profile2 regpath move account email field, into profile2 form and handle submit

I have a profile2 regpath displaying my profile2 form, and the system default account registration form below it. I need to move the account email field up into the container with the profile2 fields. ...
0
votes
1answer
37 views

form_set_error not showing error message on webform

I have created my own module and when i try to use form_set_error all im getting is the red border around the form input but no error message. here is my code function ...
0
votes
1answer
24 views

tableselect showing empty message instead of options [on hold]

I'm trying to populate a tableselect on a form of a custom module. The tableselect is actually visible, but it's displaying the #empty message. I've simplified it to this code: ...
0
votes
1answer
23 views

check box with dynamic content and error with submit handler

I have written a form that displays data with check boxes, I want the selected values to concatenate into a string. From the submit button the string would be passed as a URL.Inside the submit handler ...
0
votes
0answers
30 views

drupal 7 Warning: Illegal offset type in isset or empty in element_info

I have written the code with an idea of the core module named user, the role function. my "user_admin_types" is like "user_admin_roles". If you take a brief look at "user.admin.inc" file you will ...
1
vote
2answers
100 views

How does #value_callback really work (nested elements, …)?

EDIT: Separated 4th question. I've just recently started working with custom elements and already came across some weird behavior / questions I'd like to see answered. 1) How does #value_callback ...
0
votes
1answer
10 views

Distinguishing form being built for rendering versus submission

Is there a way to distinguish, inside a form function, that the form is being built to be rendered on the page, as opposed to being re-built as a result of submission? I would like to use ...
2
votes
1answer
28 views

7 - Panels node form, file/image gets removed when field not present in the custom form

I am using Panels to customise node forms by separating them into multiple pages. On one page I have text fields and on another file/image fields, when saving the text field form variant all the ...
0
votes
1answer
23 views

drupal7 custom form drop down show 0

I get a problem with my dropdown that shows "--select--","0","foods","meals" when I developing custom form with Drupal 7. The purpose of my dropdown is used to show "foods" and "meals" from category ...
0
votes
0answers
26 views

Dynamic data forms and reports from non-Drupal databases

I have the task of displaying non-Drupal data which is stored in SQL Server within Drupal. I need to display search pages (ad-hoc style) and results based on page and field definitions stored in a SQL ...
0
votes
0answers
18 views

Dynamic menu breadcrumb for custom Drupal form

We have a form developed using form API in Drupal 7. Based on taxonomyID & nodeID in URL, the form fields will be pre-filled. I want to display the taxonomy term & node title in menu ...
0
votes
1answer
22 views

Add an input[type=“file”] label

i need to style the input[type="file"], the only way to really style them is to add a <label> which has the same for value as the input's id. Drupal does not provide a correct label in single ...
2
votes
1answer
36 views

When are '$form_state['values'] copied to '$form' on rebuild?

as far as I understand it whenever you submit and rebuild a form (e.g. 'Add another item' on fields with infinite cardinality) something like this happens: User submits a form with filled values ...
1
vote
6answers
135 views

how to call a webservices on hook_form_FORM_ID_alter but not when the form is submitted and validation raise no error?

I have to call a webservice than dynamically modify the form. I used hook_form_FORM_ID_alter to do that. The problem is hook_form_FORM_ID_alter is also called on submit event when the form is not ...
0
votes
2answers
41 views

Building Custom Forms in Drupal 7

I'm new to Drupal 7 and installed it on my local machine to play around. I'd like to build a basic Job Posting Form and wanted to ask about questions/best practices regarding Drupal. This was the ...
0
votes
1answer
39 views

How to make form update/rebuild every page load?

Part of my custom form that gathers petition signatures includes some markup saying "last signer: Bob, 3 minutes ago", looked up from a database. But if the user does not submit the form, eg they ...
3
votes
1answer
64 views

How to preserve form values for user who navigates out of form and back?

I have a form that works, essentially, as a search / filter: foreach($search_properties as $property) { $form['properties'][$property->idProperty] = array( '#title' => ...
0
votes
1answer
45 views

Push value into array using form

I am working on developing a type of bucket that would store my selected content in some sort of data container (I am hoping to store it in an array). The selected data comes from default views, I ...