Tagged Questions

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
2answers
14 views

Removing required attribute on user entity fields not working

I have added fields to user entity and make them required and show on registration page. So the user signing up have to fill all the fields. On the admin side these all fields are coming but i don't ...
0
votes
0answers
23 views

How to call a JavaScript function inside the form_submit?

My problem is exactly as the title of my post shows. How should I call a javascript function inside the form_submit hook? I just need to call a function which is previously defined in a javascript ...
-1
votes
0answers
18 views

append new form with ajax_command_append

My task is to add multiple forms to a page, with a simple select. Eg: user selects an option in select and based on the selection, i need to add new form to the page. I wanted to do this with ...
0
votes
1answer
15 views

Changing value of min / max resolution for an image field dynamically based on a previous select list

Does anyone know if there is a way in Drupal 7 to change dynamically the value of minimum / maximum resolution for an image base on a previous select list. Example : I have a select with 3 elements ...
0
votes
1answer
21 views

Numeric field type in Form API

I am trying to add a "number" field type to a form using FAPI: $form['phone_number']['areacode'] = array( '#type' => 'textfield', '#title' => '---', '#width' => '30%', '#align' => ...
0
votes
0answers
6 views

How to reindex $form_state values' deltas when deleting or unsetting one of the options?

In a module, I provide a form to the user to select a value from a select. The form allows multiple values and the form updates itself via ajax to provide always one more select field than selected ...
0
votes
1answer
18 views

Undesired toggle effect with #states and checkboxes

I'm working on a patch for the Login Disable module, and on the settings page, I want to have two mutually exclusive options so that when one is checked, the other is unchecked. Using the FAPI #states ...
0
votes
0answers
19 views

An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (100 MB) that this server supports [closed]

Thanks in advance for your time and help. I have developed a module containing a form using Form API managed-file. The form has four file upload fields. After the first upload you get the mentioned ...
2
votes
1answer
17 views

How to unset _none option inside field collection?

Normally, in a node form you'ld unset the _none option like so: function MYMODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) { ...
0
votes
0answers
11 views

How to create a form, using a function, located inside a class

Usually when we need to create a form we create a function inside module and call: $form = drupal_get_form('function_name'); drupal_render($form); Now I started using entities and created a ...
0
votes
3answers
36 views

How to print external html output in form_submit

I have written a form that accepts user's input and based upon the input queries an external site and extracts the html of the result page from the external site. Is there a way to print html inside ...
0
votes
0answers
34 views

Using variable_get with select in a table [on hold]

Sorry if this has been asked before - I've looked and I can't find anything specific. I'm making an admin form for Drupal 7 that will allow users of a SaaS CRM (Capsule) to integrate it with Drupal ...
0
votes
1answer
18 views

selected option on drupal form not coming up first

I added a '#default_value to my drupal7 form , and it says <option selected="selected" value="81">Service</option> (this is the option I want selected) but I want it to come out first ...
0
votes
1answer
24 views

Request an Ajax form through Ajax [solved]

I want to load a form through Ajax in a custom Javascript Event as it is explained in this tutorial. I receive the form, but its ajaxified behaviour is very strange. My Javascript: var address = ...
0
votes
1answer
20 views

Set entity reference field in form to readonly

I am building a custom module to set default values for entity reference fields. To avoid overwriting these defaults, i would like to set the field readonly. While I got the defaults to work, setting ...
0
votes
0answers
13 views

Drupal Ajax Form and Output Toggle

I want to a a block with data, say DATA One DATA Two Edit Data When I click button Edit Data, It should replace data with form fields, i-e Field One and Field Two, with a submit button, after ...
1
vote
0answers
18 views

Updating multiple elements in Form Ajax Callback [duplicate]

The Form In a Drupal Form I have (amongst other elements): Two select lists: Retailers, Products. One Table select: Selected Products. Two buttons: Add, Remove The Functionality I want: The ...
2
votes
4answers
230 views

Populate multiselect options onchange of dropdown using AJAX

I have created a content type (Geological Locations) with 2 fields, Country and States. The Country field is a select box, and States field is a multiselect. So if i select a Country, the States ...
0
votes
0answers
37 views

Display search result in a form

I am building a simple custom module to search a certain node type and displaying it in the same page as the form. It is like the search function. The problem is how to display the result below the ...
0
votes
0answers
14 views

hook_form_alter logic only on certain buttons

I have an existing webform that I'm using hook_form_alter to prepopulate various fields on. It "worked" before I just added a new field. I just added a new Upload File field (a Managed file I believe ...
-1
votes
0answers
15 views

Render The Same Module Form in Content but Get the first data after submit

Im Trying to make form for accept payment first i already get the data from database this is part of my script in content : while ($row = $myquery->fetchAssoc()) { echo ...
0
votes
1answer
10 views

Form elements as arrays #tree

So I'm struggling with the concept of trees in Drupal. I have a form that presents a user with a drop down of number 1 - 27 depending on what they pick the form renders out an equal number of text ...
0
votes
1answer
9 views

Dynamic Field Adition / Subtraction using FAPI

Goal Provide a user with a drop down menu defaulted to a value of none. Other options are the number 1 through 27. Based on the value select have drupal FAPI generate a fieldset that has anywhere from ...
1
vote
1answer
32 views

Form AJAX - Update button value via Ajax

I have a custom form in Drupal that ties into Entity-generating code. In essence, there's a button which should return an ideal Entity state (determined in a method that returns true or false). The ...
1
vote
1answer
135 views

How do I know when a render array will be processed properly?

I'm still getting to grips with render arrays and there similarity to FAPI arrays is a point of confusion. I'm customizing a node form using hook_form_alter and I wanted to insert some custom markup ...
0
votes
1answer
50 views

How to remove the submit button on the form included by drupal_get_form?

I have a hook_field_widget_form where I call drupal_get_form multiple times. Here is my code: foreach ($suppliers AS $supplier_id => $supplier) { $delivery_information = ...
2
votes
2answers
40 views

How to make a reset form button without type 'markup'?

My situation: I built a form with FAPI. I display the results in a table like this: function grap_contact_repository_form_submit($form, &$form_state) { ... $form_state['results_table'] = ...
0
votes
1answer
13 views

“Preview before submitting” based on user role

So, you can make "Preview before submitting" optional or required for a node type. I would like to make it optional based on the user who is creating the node. So, for example, a authenticated user ...
0
votes
0answers
14 views

#states and language in selector - best practice

I am having trouble understanding when to use the language of the field in the selector when using #states. I have a content type of post. It has: a term reference post_type that has terms such as ...
0
votes
0answers
17 views

Why AJAX form is not inserting default values based on variables?

I'm creating a content creation form for a custom node type that will be updated with AJAX. The basic idea is that this is for processing media mentions, and the AJAX will call a function that will ...
0
votes
2answers
21 views

What is 'value' type of the field?

Could you please explain how it works: $form['support']['priority']['#type'] = 'value'; On my site this code is used to hide Priority field. But I don't understand the logic (I'm pretty new in ...
0
votes
1answer
32 views

Get ID from a URL in drupal? [duplicate]

I have cretad a menu for edit a form in drupal... Code: function pricepackages_menu() { $items = array(); $items['membership/packages'] = array( 'title' => t('Add Membership ...
0
votes
2answers
22 views

Change the value of a field depending on the selection of another

I need to change the value of a field based on the selection of another. I also don't want the user to have the ability to change this value. I tried using #disabled = true, but the values don't ...
0
votes
2answers
19 views

Form is not submit handler is not called

I have this code for calling a form and than submit it.. <?php // hook_menu function pricepackages_menu() { $items = array(); $items['membership/packages'] = array( 'title' => ...
0
votes
0answers
12 views

How to change integer field suffix base on value of other field

I have a content type property which has price as integer field and contract type as radio with options "Rent and Sale". I would like to change the price suffix depending on contract type option ...
1
vote
0answers
23 views

Is it possible to build a form with jQuery and still use ajax elements and Drupal 7 Form API?

I have a form built using for the most part many ajax elements within the form api. The form is working if a user is going through it at a normal pace however as this is to be a productivity tool, any ...
0
votes
0answers
23 views

Drupal7 managed_file form permissions

$form['search_results']['file_upload'] = array( '#type' => 'managed_file', '#title' => t('Thumbnail'), '#default_value' => variable_get('file_upload'), '#upload_location' => ...
1
vote
1answer
33 views

ajax form submit in drupal 7

I am doing an ajax form submit, Issue #1 : I am facing problem while submitting the form, The form have a submit and a validate function. In the validate function it is checking whether the username ...
0
votes
0answers
15 views

Dymanic form with ajax

I looked at ajax_example_add_more and I cannot understand what's wrong with my code. It doesn't add another field set. my code: function my_module_form($form, &$form_state) { $form = ...
0
votes
0answers
15 views

Set taxonomy value dependent on another field value in a form

I am having two fields. The first field is a select field based on a List(text) node field prepopulated with values and a second field that is a term reference, select again. I would like to be able ...
1
vote
1answer
32 views

How to change label pass field on registration form

I need to change the password field label on the registration form. Name and Email I changed through hook_form_alter and password does not work. Help me! $form['account']['name']['#title'] = 'Имя ...
0
votes
0answers
14 views

How to log empty AJAX responses?

I have simple form for product filtering, using AJAX. Callback is defined as follows: function mymodule_filter_main_category_ajax($form, $form_state) { return array( '#type' => 'ajax', ...
0
votes
1answer
22 views

How do you add information text to a Drupal 7 form?

I have this: $form['rate_the_room']['room_rating'] = array( '#type' => 'radios', '#title' => 'How would you rate the room you stayed in?', '#options' => array(1 => 1, 2 => 2, 3 ...
0
votes
3answers
40 views

How to examine existing field values and modify other field in hook_form_alter?

I have a content type with a bunch of fields attached. When displaying the node edit form I want to hide or display one field ( using $form['some_field']['#access'] = FALSE; ) if another field has a ...
1
vote
0answers
27 views

Why does managed_file not respect the #upload_location?

I've got a managed_file, with an #upload_location set to 'public://uploads'. When I upload files using the managed_file form element, uploaded files get copied to the 'public://' root, but not the ...
0
votes
0answers
28 views

#limit_validation_errors submit problem

I have a problem using #limit_validation_errors for a submit button on which I dont want all the validations to run. Here's my custom submit button : $form['actions']['draft'] = array( '#type' ...
0
votes
0answers
45 views

Customize “My account” and “Logout” Links in my subtheme with CSS button problem [on hold]

So I'm trying to shape "My Account" and "logout" links in to my omega 3 subtheme with this css: { -webkit-appearance: none; -moz-border-radius: 11px; -webkit-border-radius: 11px; ...
0
votes
0answers
11 views

block with a from with a custom handler inside a lightbox on page load

I have a custom module that generates a block with a custom form inside, this form has a custom handler where I set some session variables and some other stuff. I need to show that block in a ...
0
votes
0answers
11 views

split result into two fields from autopopulated module in D7

I have a form with 2 fields I have created a module which pre-populates field1 based on what is keyed and what is found in the db. The SQL query is getting 2 columns from the db and I would like the ...
0
votes
0answers
12 views

Add Another Item on Multivalued Field Fails on Custom Form

I have a custom module building a form with fields attached from various nodes using field_attach_form(). However, when I click "Add another item" on a field with unlimited values, a POST request is ...