All Questions
2,090 questions
0
votes
1
answer
104
views
Why does this code to create a dependent dropdown not work?
I am trying to implement the dependent dropdown option in Drupal 7 from this URL http://w3shaman.com/article/creating-ajax-dropdown-drupal-7. When changing the first dropdown value, it is showing the ...
-2
votes
1
answer
1k
views
Serialization of 'Closure' is not allowed in serialize()
i am in the midst of fixing our website (which is built using Drupal version 7.67) that shows many errors after the PHP version is updated into PHP 8.0.
One of the errors that i am stuck now is this ...
0
votes
1
answer
838
views
Call #ajax when a checkbox is checked or unchecked
I have a Drupal 7 form that I want to be a single checkbox. When the checkbox is checked, I want to call an ajax request that hits an API to update the value, same for when I uncheck it. However, this ...
-2
votes
1
answer
20
views
How can I loop on checkboxes to hide all using mlid: from the datatable?
function ts_core_form_menu_overview_form_alter (&$form, &$form_state, $form_id) {
$form['mlid:11242']['hidden']['#type'] = 'hidden';
$form['mlid:11246']['hidden']['#type'] = 'hidden';
$...
0
votes
1
answer
71
views
How can I access or expose the Commerce data in $order->data[] to the Rules module?
Following this old checkout_pane_example.module tutorial, I created a custom Drupal 7 Commerce checkout pane. It's simply a text field to collect special order instructions from the customer.
...
0
votes
1
answer
71
views
Time spent with custom module
Can anyone help me with this, I want to activate time spent module on my custom form module, and store the time spent on a field on my form. I think that I could do it on the file timespent.module ...
0
votes
0
answers
68
views
Altering user_admin_account and user_register_form
I'm pretty new to Drupal and I'm trying to build a Drupal 7 custom module to alter the user listings table in admin/people. I would like to display the first and last names of the users.
I've already ...
0
votes
1
answer
86
views
hook_forms() not working
I'm trying to add a button to all node forms via callback in hook_forms. I get a similar error. Can someone help.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '...
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
48
views
Form doesn't update via hook in edit mode, instead of it page reloading
This is not happening all time (possibly for big amount of existing field, I'm not sure, with less amount of fields form is saving as it should) when I'm adding new Field collection entity or update ...
0
votes
0
answers
70
views
How can I conditionally override the field description?
I am using the Reference Field Option Limit module in Drupal 7 and I want to change the explanation text that says:
No options are available for the current form values..
I want to put instead:
...
0
votes
1
answer
106
views
Autocomplete field where title is replaced with NID
I'm using Drupal 7 and I have made autocomplete function to be called on a field.
File my_module.module:
<?php
function my_module_menu() {
$items = array();
$items['/...
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 ...
1
vote
0
answers
59
views
Copy a field's value to another field and modify it
I have content type "Video"
When i do a new "video" I have a field "iframe_vimeo" thats it contains a value of the iframe's video link.
I want to do some modifications ...
0
votes
1
answer
226
views
Set Default Value for Image Field contain Multiple Images
I've added a multiple image field to the user account that uses the multiupload_imagefield_widget and it works when I edit the account.
On the other hand, I have a custom module with a form that I ...
1
vote
1
answer
363
views
drupal_set_message doesn't display message sometimes
I'm uploading a file, to process and display a message at the end. However, the messages that drupal_set_message is set to display are displayed sometimes and don't display sometimes, even, if the ...
0
votes
1
answer
809
views
How do I add the "onload" attribute to a script tag?
I need to add the onload event in jquery script tag as advagg does. I have done a bit of research, and I found that they are actually invoking hook_element_info_alter() and thereby add their ...
0
votes
1
answer
1k
views
How to limit form submission per user per day and week?
The goal is very straightforward. I need a form to limit each user to 1 submission per day and 3 per week.
What I found:
Webform:
The "Form settings" in webform has the "Per user submission limit" ...
1
vote
1
answer
19
views
Why do D7 form builders have a $form parameter?
In Drupal 7, the first parameter of a form builder function is $form.
When implementing a form builder function, one has the option of either adding stuff to this existing array and returning it, or ...
0
votes
1
answer
493
views
Delete confirmation as popup
I have a view containing saved user webform drafts set up in a table format. I have given permission to the authenticated user to delete own submissions. When clicking the delete link located on the ...
0
votes
1
answer
66
views
login form generated by drupal_get_form('user_login_block') does not log in
I have a custom module part of which builds a block with the login form
function my_module_block_view($delta = '') {
switch ($delta) {
case 'awsImage_public_info_forms':
$user_login = ...
0
votes
0
answers
24
views
Field gets unset and fails validation in user edit form
We have a special date field that we set upon user creation when our custom user form is submitted. The user does not have to set this field themselves.
We have a separate form, which is a user edit ...
0
votes
1
answer
119
views
Second managed_file upload field fails with "An unrecoverable error occurred"
I have a form with two (ajax enabled) upload fields.
Submitting a file to the first one works, then submitting a file to the 2nd does not, giving
An unrecoverable error occurred. The uploaded ...
0
votes
1
answer
241
views
Enable a button basing on multiple form values being equal
I would not like users to be able to submit a form until:
All fields are filled out
The password and confirm password fields are equal
I can do this with JavaScript, potentially, but then the ...
0
votes
1
answer
827
views
How do you add help text to a form item?
I would like to change the help text for an input field. My form ID is views-exposed-form-events-page-1. I have a text field that I want the helpful hint to appear below. The field ID is edit-field-...
1
vote
2
answers
603
views
How can I make the coupon code field in commerce mandatory?
Using D7 commerce coupon/discount modules. I need to make the coupon field mandatory. Every order needs a coupon code entered.
There is no standard "required" checkbox on the field and I tried using ...
0
votes
1
answer
87
views
Alter Add to Cart form POST data provided by #action
I am going to be phasing out Drupal Commerce on our website in favor of a new custom built application that is hosted at another URL. Without completely rebuilding everything I am trying to override ...
0
votes
2
answers
38
views
Form submission handler is not executed
In a module, I am using the following code.
function mysimple_form($form, &$form_state) {
$form['#method'] = 'get';
$form['#action'] = '/buy/{_val_}';
$form['search_location'] = array(
...
0
votes
0
answers
20
views
dropdown multiple values
I am trying to display multiple values of drop down and store it to the database. How could I do that?
Any help would be appreciated.
$form['options'] = array(
'#type' => 'value',
'#...
0
votes
1
answer
144
views
Display the results of a form submit on the same page just under the form
I have created a form and it takes in 3 values which are Brand, Item and Zipcode. The values are queried and the results are fetched the database table. I want the results to be shown in a table
...
1
vote
2
answers
955
views
Change remove from cart button to an image button
I want to change the remove-button, that removes line items from the cart to an image button representing a trash can like this:
The code I am using in a custom module looks like this:
<? php
...
0
votes
1
answer
246
views
How to alter the search api views exposed form field value?
I have a search api view. Which has an exposed some exposed filters.
The exposed filters contains postal code, city and latlong field.
The user will enter the city and postal code and then in the ...
0
votes
0
answers
139
views
Dynamically created elements trigger wrong submit handler post AJAX event
I've found that dynamically created submit handles will adopt the first declared submit function in a form after an AJAX event has been processed. Demo code:
<?php
function form_test_main_form($...
0
votes
1
answer
91
views
How can I hide a field in the node add form but it unhide it on the node edit form?
I'm having a content type in that I want a field "Status" to be hidden in add content form page(I'm setting default value in that add content). Now I want that field to appear in edit form page of ...
0
votes
1
answer
21
views
Changing the html and order of system fields(pass/email/locale/etc) of user edit form
I have changed a number of forms accessible by users to fit a certain style. To do this I used an #after_build function that adds prefixes and suffixes to fields, as well as a bit of javascript. This ...
0
votes
1
answer
1k
views
Hook form alter to check date field is empty or not
I'm using hook_form_alter() to add some custom validations. I have to check if a date field is empty or not; when the field is empty, I need to display an error message.
I don't know how to get the ...
0
votes
1
answer
349
views
Form is not submitting after ajax callback
I have a form which has a checkboxes field.
This field has an ajax callback attached
$form['checkboxes'] = array(
'#type' => 'checkboxes',
'#title' => 'test',
'#ajax' => array(
'...
0
votes
2
answers
44
views
Hide one form element until another is selected
Is there any way to disable the field 'model_article_nr' until 'model' is selected
this is what i have and as it is now i can select 'model_article_nr' before i have choosen a model which leads to ...
0
votes
2
answers
576
views
Form rebuild without using buttons
I'm trying to figure out how to rebuild a form without using a button click trigger. Instead, I'm looking to rebuild whenever a blur event occurs on a textfield. All non-button form types lack the #...
1
vote
1
answer
705
views
How to keep checkbox checked after form submit
I am trying to keep checkbox "checked" after form submit and page load. I have following simple code from .module file.
<?php
function my_module_menu() {
$items = array();
$items['...
0
votes
1
answer
111
views
How to set "Language Selector dropdown" required in node form
I want to know How to set "Language Selector Drop-Down " required in node form?
I tried to do this via hook_form_alter, but it seems $form['language'] is not created in this hook !
Is there any hook ...
0
votes
1
answer
3k
views
Programmatically change the weight of a form element
I have a user activation/registration form with different attribute like
Captcha and security questions which are coming from different modules.
I want to change the display order of form elements.
...
0
votes
0
answers
770
views
Uploading xlsx-file changes permissions of the file? Errors when loading via PHPExcel
My goal is to let the user upload a xlsx-file and then read the file to create objects.
So i created a file upload page in my custom module where the user can upload a file via the 'file' form field ...
1
vote
0
answers
18
views
Set a field value with FAPI states
Does anyone know if there is a way to set the value of a field with states?
E.g. If "this" is checked, set input value to "0"
Something like....
$form['booking_process'] = array(
'#type' =&...
0
votes
0
answers
57
views
AJAX in callback function
I'm trying to convert old code written in standard HTML/PHP/Javascript/JQuery into a format (more) consistent with Drupal. The code consists of a form with interactive elements (regulated by ...
0
votes
1
answer
1k
views
How can I add an AJAX callback to a checkbox?
I am using taxonomy manager module I want to add ajax callback to checkbox tree view for checkbox is checked condition but it is not working can some one please suggest me. I have modified the code ...
0
votes
2
answers
383
views
How do I get the form submitted data in a custom module? [duplicate]
I have create a webform in Drupal 7. I want to access the submitted data in a custom module.
I used my_module_form_submit($form, &$form_state) but no data has been found.
Please Help.
0
votes
2
answers
169
views
just want to change checkbox value while submit
I am using drupal 7:
$form['title']['#tree'] = TRUE;
$form['title']['node_first'] = array(
'#type' => 'checkboxes',
'#options' => array(
'value' => $value->title,
),
)...
0
votes
2
answers
77
views
Views callback work only once with advanced form block
this code work but the views is callback only once (reload only once), any idea to reload more than one time ?
see in detail on drupal.org
function modulename_form_alter (&$form, &$...
0
votes
0
answers
24
views
Validation after all other validations were successful
I have a form with several form fields and two validation handlers.
function my_module_my_form_validate_integer($element, &$form_state) {
// validation stuff
}
function ...