All Questions
99 questions
25
votes
3
answers
15k
views
Multiple Values to Trigger #states
How can I have multiple values trigger the Form API's #states?
Say for example, I wanted this field to be visible not only if the value is 5 (currently works below), but wanted to make the field ...
12
votes
2
answers
7k
views
Right way to add JS and CSS to node/edit and other forms
I am making a site with a lots of JS, and I am wondering where I should put the JS code. Optimally I would like to keep the JS with each module and not the theme layer. Some content could be exposed ...
10
votes
8
answers
25k
views
How to add a JS confirmation popup when clicking an #ajax button
I have a basic FAPI button input that is #ajax enabled and that's working fine, but I want to add a JS "Are you sure?" confirmation popup when clicking the button before the code actually runs, and I'...
10
votes
4
answers
21k
views
How to make form buttons call only javascript?
I'm experimenting with JavaScript and Drupal forms. Currently I'm trying to make a button in the administration form of a module that will use JavaScript to append options to a select list. The ...
7
votes
3
answers
9k
views
Can I attach a jquery.ui.datepicker widget to a form element using the form api?
I have a generic form element:
$form['date'] = array(
'#type' => 'textfield',
'#title' => t( 'Date' ),
);
That I want to add the jquery ui datepicker to this element. Is there a way to ...
6
votes
2
answers
6k
views
How to extend or "hook" Drupal Form AJAX?
I'm working with standard admin form, which has 'add_more' button for one of fields.
My task is to move some fields to jQuery UI Dialog just for usability. When dialog was closed I manually append it'...
6
votes
2
answers
604
views
drupal_add_js and drupal_flush_all_caches
I was trying to call drupal_add_js in the callback of a button. It seems, even with after_build, that this can be done successfully only you are working without cached data.
So, before i start the ...
5
votes
2
answers
5k
views
custom module: drupal_add_js and drupal_add_css do not work after form validation?
I have created a custom module that changes the layout & adds extra functionality to one of my content type creation and edit forms.
It works beautifully and as expected apart from when I submit ...
5
votes
2
answers
1k
views
Setting date_popup year range to more than the 3 years default in Drupal 7
I have a custom module and using date_popup. Currently the popup only shows a 3 year range in the date popup.
$form['startdate'] = array(
'#type' => 'date_popup',
'#title' =&...
5
votes
1
answer
4k
views
How to add variables to Drupal.settings using form#attached?
I found this example: http://deeson-online.co.uk/labs/how-use-formattached-javascript-setting-drupal-7-form-api
I tried:
$form['#attached']['js'][] = array(
'data' => array(
...
5
votes
1
answer
15k
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 ...
4
votes
1
answer
5k
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',
);
$form['#...
4
votes
1
answer
3k
views
How to pass Javascript variable with form on submit?
I want to pass a variable created with Javascript to $form_state so that I can use this variable in the form_submit function.
In an ajaxified form I can use:
Drupal.ajax[ajax_el].options.data....
4
votes
2
answers
4k
views
How to trigger a form and pass variables to $form_state with jQuery?
What is the way to trigger a Drupal form via JavaScript, and pass new values to $form_state while doing so?
I have a main form, which has an element that triggers a jQuery UI dialog with a form in it. ...
3
votes
2
answers
6k
views
How to auto-submit a form using Drupal Form API?
I need help with making a drupal form. I've made the form and it works perfectly fine, all it does is capture the email, ip, and date and time of a user. The problem is I don't want the user to have ...
3
votes
3
answers
1k
views
Add JavaScript to a node form
I'm trying to add a custom JavaScript file to the forms to create or edit a node.
I've tried mythemename_preprocess_page(), hook_form_alter() and theme_content_type_node_form(). They seem to pick up ...
3
votes
2
answers
716
views
What are the alternatives for storing client side encrypted data?
I want to store client side encrypted data in Drupal 7, so that it is encrypted on the client end, and stored and transmitted in encrypted form. The password is never transmitted or stored on the ...
3
votes
2
answers
3k
views
Is there a callback for the managed_file form element, called on succesful upload?
Is there a Javascript/PHP callback for the managed_file form element that is invoked when the file is successfully uploaded? (I mean when the "Upload" button is clicked, not when the form is submitted....
3
votes
1
answer
1k
views
Any better popup modal framework in drupal
I use the Chaos tool suite module for modal popup in Drupal 7; I am unable to open popup from within a popup using ctools. Can it be done using ctools, or is there any better popup modal module in ...
3
votes
0
answers
2k
views
Multiple date picker for date popup widget
I've been searching for a while, but didn't find any contribute module to store multiple date values picking them from only one date popup calendar widget, just a 2009 feature request for D6.
In D7 I ...
3
votes
0
answers
2k
views
"Uncaught TypeError: Cannot call method 'call' of undefined at 507 jquery.validate.js" [closed]
I am trying to implement clientside validation using the clientside validation model. I have been following the documentation located here. Specifically the Form API Section for Drupal 7. I believe I ...
2
votes
3
answers
8k
views
Fire javascript on a form submit
Even the searching I have done that looks like there may be a solution doesn't really seem to answer this.
I have a form with an input value. When the user enters a value and clicks submit, I want ...
2
votes
1
answer
2k
views
How to validate webform with JavaScript?
I've got a Webform for which I need additional calculations to hidden fields.
I've added a JavaScript file to the page by using drupal_add_js. And let that be the only part that works...
My ...
2
votes
2
answers
2k
views
Form API focus on first input
When my form load I would like to set the focus on the first field in the form. I know I can use jquery to do this by doing $('inout id').focus();. Where would I put this code so that it only runs on ...
2
votes
3
answers
3k
views
Is there a way to re-invoke #ajax on forms when the form itself is returned with ajax?
I want to change the delete link on comments so that the delete confirmation is returned with Ajax and then the delete confirmation is executed with Ajax.
I have fixed the form so the delete ...
2
votes
2
answers
2k
views
How can one add inline JavaScript in the validation function for the Form API?
I found that there is a way to add javascript files in the form validation function as stated in "drupal_add_js not work in form validation failed".
However, I would like to know how to add ...
2
votes
1
answer
2k
views
jQuery events are lost after form reload
First I thought that this would not be a Drupal specific problem, but jQuery specific solutions didn't solved it. I hope you have some advices.
I have a form with lots of fieldsets. To find the right ...
2
votes
1
answer
725
views
Why is my form_state being reset after submission?
I have a menu item with page callback:
function my_menu() {
$items = array();
$items['my/action/%ctools_js'] = array(
'title' => 'do something',
'page callback' => 'my_action',
'...
2
votes
1
answer
820
views
Why does $form_state['input'] not correspond to the html of the form upon submittal?
I have a drupal form with repeatable fields allowing to type in as many phone numbers as one wants. Simplifying to the extreme, the code looks like this:
function form_test($form, $form_state) {
$...
2
votes
1
answer
2k
views
Giving Add and remove option to select and deselect from one list to another
I want to make user able to chose from one list of select options to another . A good example is in the picture here .
. Could you please tell me if there is a module to achieve this?
I tried using ...
2
votes
1
answer
412
views
Using clientside_validation project, default validation plugin message not being overridden for states dependent field
I am currently using clientside_validation with clientside_validation_states to validate conditionally required fields.
The issue I am experiencing is when the conditionally required element is ...
2
votes
4
answers
4k
views
How to add css classes to modal forms module
My Problem
I'm trying add CSS classes to help me style the modal forms created using the Modal Forms module.
I have a User Login and a User Register form at the moment, but they have no form ...
2
votes
1
answer
1k
views
Button with Drupal Behavior jQuery Conflicting with AJAX 'Add More' Button on Unlimited Cardinality Field
I have a form with an unlimited cardinality field that creates an 'Add more' button to add more fields. I also have a separate pair of fields. One of these fields has a value prepopulated on starting ...
2
votes
1
answer
67
views
Override one line in core tabelselect jQuery behavior so custom checkboxes aren't affected
I have created a custom table using a Form API tableselect element, and within my table, I have embedded a checkbox form element that is checked based on an entity field (see here for details). The ...
2
votes
0
answers
1k
views
How to tell if user selected an autocomplete option in a form? [closed]
I created a form that has an autocomplete field of registered users and it is attached to nodes. In the form validation function I check if the string of the textfield is a valid user but in order to ...
2
votes
2
answers
2k
views
Trigger jQuery "add more" multiple times
I have a form that I am filling with default values in hook_form_alter. Some of the fields are in a in a field group and I need to trigger the "add more" button using code.
I figured out how to send ...
2
votes
0
answers
115
views
Creating ajax forms with ajax
I have been trying to implement popup forms that load dynamically, which initially seemed pretty easy. My current method is to echo the form from a menu callback, and insert it where needed with js. ...
2
votes
1
answer
2k
views
Add JavaScript 'effects' to be used with AJAX form submissions
Consider the following code:
$form['actions']['submit']['#ajax'] = array(
'wrapper' => 'apple-node-form',
'callback' => 'node_add_callback',
'method' ...
2
votes
1
answer
598
views
WYSIWYG error when using managed_file and AJAX
I have a form that has both a managed_file element and a text_format element. Both are encapsulated in a wrapper div (using #prefix and #suffix). On submit, an AJAX callback is executed and both ...
1
vote
1
answer
10k
views
How to display a confirm box before submitting a form?
On the node/%/edit form, when the user clicks the Submit button, I want to show a simple pop-up box with the text "Are you sure you want to save your changes?". When the user clicks Cancel (or No) ...
1
vote
1
answer
4k
views
EntityMalformedException: Missing bundle property on entity of type node in modal
I want to open create content type in modal, according to modal form and modal api example, I implement it, I test
the problem is here
when I test it by contact form
ctools_include('modal');
...
1
vote
2
answers
111
views
How to exclude forms from processing by Hide Submit module?
According to module description this is possible.
However I didn't find how to do it and I did not able to exclude form by any way, e.g:
http://drupalcode.org/project/hide_submit.git/commit/8aab1ab
1
vote
1
answer
168
views
form attached JS attributes
I'm trying to convert this:
<script type="text/javascript" data-main="/Scripts/submenu/main" src="/Scripts/require.js"></script>
into something like this:
$form['#attached']['js'] = ...
1
vote
1
answer
20k
views
How to prevent newline character in textarea [closed]
I'm building a form in a module for Drupal 7 and I want to add a textarea as I would like it to be multiline so that text overflows on the next line, etc. but I don't want users to be able to create a ...
1
vote
3
answers
4k
views
Ajax callback of select form field not triggered when changed by javascript, only when changed manually
I have a simple ajax form with select form input:
$form['children']['number_children'] = array(
'#title' => t('Počet detí'),
'#type' => 'select',
'#options' => range(0, 15),
'#...
1
vote
1
answer
157
views
How to dynamically populate radio button widget in DrupalGap (with InApp Purchase Products)?
I am pulling products from the iTunesConnect using the in-app-purchase cordova plugin and want to show the valid products (title) in a radio button list.
The store.('product')update function renders ...
1
vote
1
answer
1k
views
Open form module from popup [closed]
I have a basic module that I made for a survey/email collection form for a site I'm building. I'm very new to drupal and drupal development and I'm trying to figure out how to open this module on the ...
1
vote
1
answer
4k
views
Reload Javascript after ajax event
I have a module that uses a button to load an embed view everytime the button is clicked.
// function to print builder view
function workout_builder_template() {
$viewName = 'builder_view'...
1
vote
1
answer
325
views
Is there any way to use a jQuery overlay to confirm/reject node deletion?
When I delete a node (any type of node, presumably), I'd like to have the confirmation happen through a jQuery-like yes/no dialog popping up over the page, rather than being redirected to a separate ...
1
vote
1
answer
1k
views
How to tell if a function is being called by javascript?
I have a validation function that is being called either from another php function or a JavaScript call. I was wondering if there is a way to determine if the function is being called by JavaScript so ...