All Questions
99 questions
0
votes
1
answer
99
views
Inline Javascript throws an error on drupal_add_js() within an AJAX callback
I am trying to get JavaScript to measure a text field and auto submit at a character limit for an Ajax callback to be validated against a Luhn Algorithm and errors out on failure to validate.
I found ...
0
votes
0
answers
46
views
Checkbox Form Element: Displaying checkboxes value based on on/off
I have a checkbox form element that uses taxonomy terms via variable_get as #default_value; storing the result. I don't want to overwrite value, I just want the form to render/display checked ...
0
votes
1
answer
2k
views
How do I enable an onclick event in a link on a form?
I am using the following code.
$form['test'] = array(
'#type' => 'link',
'#href' => "javascript:;",
'#title' => t('Show'),
'#attributes' => array(
...
0
votes
1
answer
509
views
Using JCF with dynamic forms
I want to use Javascript Custom Forms (JCF) to get more attractive and consistent looking forms on my Drupal 7 site. I've got it working to a degree, however when the form changes with AJAX, the new ...
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 ...
0
votes
1
answer
220
views
How can I toggle required field?
Using Drupal 7.
I'm trying to toggle required field based on the click of a radio button.
I already tried the proposed solution in this post but it did not work.
Here is my code:
$(context)...
0
votes
1
answer
58
views
Fancy insert stopped working
Does anyone have an issue with the fancy insert module, not actually inserting the image on click recently?
It looks like the javascript in the fancy insert was hooking into the insert button by ...
0
votes
1
answer
680
views
How to hide clientside validation error message
Right now, I am using Clientside Validation. Everything works perfectly. But I would like to remove the error message which I set it showed at the top of the form. In the meantime, I would like to ...
0
votes
1
answer
298
views
Attach behavior only to the file upload button
I have a form with a managed_file field where I need to know when the upload button is clicked, and then perform an action. I decide to make it by attaching a behavior to my button but it also trigger ...
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
860
views
Trigger an event when file is upload on managed_file field
I'm trying to trigger an javascript function when a user select an image for a managed_file field and click on the upload button, not the submit one.Except that in Drupal 7, managed_filr field do not ...
0
votes
1
answer
2k
views
How to clear a field using jquery after Ajax form reload [closed]
I have a custom module with a custom form with two fields: field A (select), field B (datepicker). When the user picks field B, it launches an Ajax call to validate field B. All works well so far, ...
0
votes
1
answer
626
views
Using 'return' with an ajax callback renders an entire page before my content is loaded
I'm developing a module that uses Openlayers maps and Drupal Commerce. When you click on the map, you should see products that relate to those coordinates of where you click. I have this working ...
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
686
views
Drupal.attachBehaviors only working for some fields when using Ajax .load
The following code works for some things that I do in terms of .load() such as adding Chosen to fields.
But it won't do anything to date fields, conditional fields or field groups. They get left with ...
0
votes
0
answers
109
views
Form error messages are not displaying in colorbox
I have a custom form which is displaying in a colorbox.
But the problem is when I set an error in validate function using form_set_error, the red border appears against the field but the error ...
0
votes
1
answer
221
views
ajax pager working depends on if js file is loaded in module .info file
I'm using the code I've outlined in my blog post for a custom image search, and I'm having a problem with the pager, but only on one site. The first page of results renders just fine, but when I try ...
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' =&...
-1
votes
1
answer
2k
views
TinyMCE textarea not editable
I have integrated tinymce in my form, inside a modal.
$form['myid_templates_editor']['text-modal'] = array(
'#type' => 'text_format',
'#format' => 'full_html',
'#prefix' =...
0
votes
1
answer
50
views
The correct way to include jquery in a module's form
I'm trying to use jquery in a form of mine that is rendered via the form api.
How i'm getting jquery to work now is like so
$form['raf_raffle_name'] = array(
'#type' => "textfield",
"#...
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 ...
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 ...
1
vote
0
answers
678
views
jQuery clone of an select form with ajax event
I'm trying to clone with jQuery the block which contain a form with an ajax event.
function module_api_change_currency_form($form, &$form_state){
$form['currencies'] = array(
'#...
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 ...
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 ...
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 ...
0
votes
1
answer
903
views
Conflict between ajax callback and jQuery UI dialog
I have a button that triggers an AJAX callback with the form api like so :
$form['show_modal'] = array(
'#type' => 'submit',
'#value' => t('Some crazy text'),
'#ajax' => array(
'...
1
vote
1
answer
818
views
#states not detecting a change to form via ajax_command_invoke
I have a form. On an elements I have an ajax call back.
In the callback I use the commands[] to update some elements on the screen.
One of the elements i have updated is used by another form element ...
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'] = ...
0
votes
1
answer
2k
views
How can I execute a JavaScript function before the form submission handler is called?
I am trying to save an image using the following code.
function mymodule_user_page_form() {
$form = array();
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
'#...
1
vote
1
answer
752
views
Is it possible to append Media's file browser to a certain node type?
I have a certain node type with a canvas on it, allowing users to draw on the node. Basic functionality such as lines are working, but I'd like to allow people to upload images to it as well. Since ...
0
votes
0
answers
372
views
How to trigger ajax Form API action by js [duplicate]
In a custom form you can add an #ajax property, e.g.
$form['some_element'] = [
'#type' => 'textfield',
'#title' => 'Foo',
'#ajax' => [ 'callback' => 'foo_callback',
...
0
votes
1
answer
1k
views
How to do autocomplete in a Bootstrap modal form?
I've got a D7 page that constructs a Twitter Bootstrap modal form; it appears in response to a click on a button on the page. I'd like to have in that form a textfield that uses the standard Drupal ...
1
vote
0
answers
83
views
How use geofield_openlayers in custom module
I'm writing a drupal custom module, in my form I need a geofield with openlayers map widget.
I can create a geofield_openlayer by using Content type, but I don't know how can I create the field in my ...
0
votes
1
answer
2k
views
Dont Refresh Drupal's Page after a button is click in Forms API [closed]
I had started developing a module in Drupal. I made two form controls: a fieldset and a button. The button calls a javascript function "myphoto_options" when it is click. This function only does an ...
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 ...
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....
0
votes
1
answer
2k
views
How to add special character validation on specific field in form registration process
I want to add a special character validation on a specfic field.
Here I have my code but it does not work and there is no error.
function mymodule_form_alter(&$form, &$form_state, &$...
1
vote
0
answers
122
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
1
answer
927
views
Form validate without submit action
I'm developing a site that it will use Services for the CRUD operations and ANGULARJS for the comunication frontend <-> backend.
Now when I want to insert a new content of content type FOO I will ...
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 ...
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 ...
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 ...
1
vote
4
answers
5k
views
Execute jquery function if Ajax callback form complete
I got a custom ajax callback which replaces my checkbox options based on the select option.
Now after the checkboxlist get's updated i need to execute a jquery function on those checkboxes.
How can ...
0
votes
3
answers
3k
views
create a downloadable file after submit webform
Hello Im not sure if this can be done, but Im trying to make a simple app where you create your own lexical analyzer.
So in the webform I ask the necessary information, then I need the following:
...
-2
votes
1
answer
156
views
Change value input field according to other fields
I have 10 input fields when you create a product (= node). I have an input field amount, price & reduction and sell price. So when the field amount, price & reduction are filled in I want to ...
0
votes
1
answer
434
views
How to retrieve sumbitted data in modal
I want in add content have a link(or button) when user click on lt the popup (modal or any popuping method like dialog,modal,lightbox,colorbox ) will open, in that form I want have some field, like ...
0
votes
2
answers
1k
views
Validate date selection in date picker
I am using a javascript datepicker to allow users to select a date (which I have functioning in my form). What I don't know how to do is limit the dates that can be selected. Is there a way to do this ...
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['#...
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');
...