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
1answer
8 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
8 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
15 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 ...
-2
votes
0answers
24 views

how to create depented states, cities for all countries in D7 [on hold]

please help anyone.. i am now creating simple web form for registration in drupal 7. in this form i am already create country, state, city drop down field. It works smoothly for default country. ...
1
vote
1answer
125 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
33 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 = ...
0
votes
0answers
17 views

Notice: Undefined index: #field_name in file_managed_file_save_upload()

$form['logo'] = array( '#title' => t('Logo'), '#type' => 'managed_file', '#description' => t('Upload logo'), '#default_value' => variable_get('logo', NULL), '#upload_location' => ...
2
votes
1answer
25 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
12 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
11 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
2answers
17 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
30 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
18 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
15 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
11 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
17 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
18 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' => ...
0
votes
0answers
27 views

How to add a confirmation dialog for a submit button? [on hold]

There is a submit button in a form: $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), '#submit' => array('_shoes_submit_cart'), ); I'd like to popup a ...
1
vote
1answer
30 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
13 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
7 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
27 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
13 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
19 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
35 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
21 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
22 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
35 views

Customize “My account” and “Logout” Links in my subtheme with CSS button problem

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
10 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
10 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
3 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 ...
0
votes
1answer
18 views

hook_form_alter Save $form['account']['field_first_name'] into $form['profile']['field_first_name']

Hi I'm trying to save a field into another field in the same form when the form is submitted. I've tried using hook_form_alter and checked for count($form_state['input']) > 0 to save ...
0
votes
1answer
13 views

Form API Submit Button for Multiple Forms

I created a module with 3 forms on it. Is there a way to only have one submit button at the very bottom of the page that will store all three values?
1
vote
0answers
24 views

Disable past dates in date_combo

Is there a way to disable the past dates in the date pop-up while using the date combo form api? Specifically, I have a date type field in a content type, on which I want to do this. Help ...
3
votes
2answers
55 views

How to adapt #prefix/#suffix for each option in radio form using hook_form_alter()?

I need to modify the html code of radio buttons generated by Ubercart Attributes. So I want to do it using hook_form_alter(). If I dsm() the $form I need to change using hook_form_alter() I get ...
1
vote
1answer
25 views

Sanitizing User Input using Form API - Creating Nodes

I'm using D7 Form API to make some custom forms for users that create nodes on submit (using node_submit & node_save functions). This is an example form I'm using: function ...
0
votes
0answers
6 views

registration form disable required username

I'm using the logintoboggan module, so that users identify with email and password. Everything works fine, with exception of that on the registration form is required to put a user name. It must ...
0
votes
1answer
18 views

Ajax Request Failing

I've got a perplexing issue which has left me quite confused. I've got a form which has a link on it and when the user clicks the link it is supposed to open up an AJAX popup form and display some ...
1
vote
1answer
37 views

Drupal form elements in html table, label (title) rendering

How to place title/label in other cell of the html table I have: function hook_theme() { return array( 'hook_form_table' => array( // The renderable element is the form. ...
0
votes
1answer
31 views

form element ['#attached'] does not load setting

I have this in a form alter hook of a specific node type: $form['title']['#attached']['js'] = array( array( 'data' => drupal_get_path('module', 'mymodule') . '/js/autosuggest.js', ...
0
votes
1answer
32 views

How to make sure my behavior is triggered before AJAX?

I have a form elements that looks like this: $form['properties'][$property->idProperty] = array( '#title' => $property->Label, '#ajax' => array( 'callback' => ...
0
votes
0answers
29 views

Calculate webform total from select list fields

Like e.g. there are two select options type components that has various amounts of $ to select from. So if user selects in one field $100 and $200 then the next field below it would generate the total ...
0
votes
1answer
24 views

Drupal Json Output strange characters when pulling from other language

Hi Fellow drupal experts, I have a problem, I developed a custom page intended to do a drupal json output : and here is the code : function blogpull_menu() { $items = array(); ...
0
votes
0answers
18 views

Displaying custom form on a node page

I have created a form using form-api. I want to show it on a page called career. Anyone having any idea how to do that? Any help will be appreciated..Thank you! Here is my hook_menu() code: function ...
0
votes
1answer
27 views

How can I make a field appears when you check on a checkbox?

I'm making a module and on the administration page there is a form and I want to make one of the fields appears only when user check on a checkbox. Like the option to add a new content to a menu.
0
votes
0answers
40 views

AJAX callback not working on select list added via previous AJAX call

I have a large custom form using the excellent FAPI. A select list element is added through AJAX when a certain option is selected from a previous select list. This is working great, and the select ...
0
votes
0answers
20 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
21 views

TABLESELECT how to add two textfields in one cell? [duplicate]

How to add two textfields in one cell of table ? function fields_menu() { $items["fields"] = array( 'title' => 'test fields', 'page callback' => 'drupal_get_form', ...
2
votes
2answers
98 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
53 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 ...