All Questions
256 questions
1
vote
1
answer
191
views
Monitoring field changes in custom content type
I have custom content type with "price" field.
I would like to log the information about when the price has been changed (by administrator). All I need is date and old/new value of that field (for ...
1
vote
1
answer
263
views
How can I set a default node owner for anonymous nodes on the node edit form?
This question is refining the poorly asked Is there any easy way to set the default author for a node being edited to the current author if it is currently anonymous?
The site I'm working on has a ...
1
vote
2
answers
1k
views
how to implement Ajax callback on form_alter for entity field?
EDITED: I am able to display image for a field dropdown which have entity reference values to another content type. That is when a node content is edited or created.
Note: I'm not creating form ...
1
vote
0
answers
921
views
Use a custom JS modal to confirm changes made on node add/edit form before submit
I basically want to do what confirm_form does, but in a custom modal (I am gonna use a JS plugin to generate the confirm modal).
So what I have is a large hook_form_alter, and I am using the ...
1
vote
2
answers
1k
views
Form ajax add more button added via another ajax callback not working
I have a form button which I want to add another field with another button on that form( I am able to do this) but second button is not clickable. Any idea. Following is my code-
This is my form code-...
1
vote
3
answers
737
views
User register and login functions are called from hook_form_alter, but user isn't logged in
Background
I'm attaching the user register form, to the node create form with hook_form_alter. that way I create a node and user at once.
In order to validate and register the user, in ...
1
vote
1
answer
285
views
How to pass a value from form(block) to the page and show this page?
I created a block with a form (elemnts: textfield and submit). Also have a page created by the hook_menu. I want that when you click on submit in block, the value from textfield transmitted to a page ...
1
vote
1
answer
2k
views
How to add a 2nd submit button to a node form?
I need to have an extra Save button at the top of my node form.
Pressing the 2nd button should do the same action like the regular one.
The following code creates a 2nd save button:
function ...
1
vote
1
answer
4k
views
how to check in ajax form callback if form for failed validation
I have a form and on and implemented a ajax submit callback which calls this function:
function popover_ajax_callback($form, &$form_state) {
// watchdog("ajax_callback", "testing ajax ...
1
vote
1
answer
535
views
Alter taxonomy autocomplete value
I need to alter the element value of a taxonomy autocomplete field before it is processed and can't seem to find a way of doing so.
taxonomy autocomplete fields have an element validator attached, ...
1
vote
1
answer
769
views
D7 comment form doesn't submit
I've successfully printed a comment form on a views-built page using a PHP Views field (as found in this question). The form doesn't submit right away though - instead of submitting, the comment "save"...
1
vote
6
answers
200
views
how to call a webservices on hook_form_FORM_ID_alter but not when the form is submitted and validation raise no error?
I have to call a webservice than dynamically modify the form. I used hook_form_FORM_ID_alter to do that. The problem is hook_form_FORM_ID_alter is also called on submit event when the form is not ...
1
vote
5
answers
3k
views
How to hide the "trimmed version" from the preview page?
When I "preview" a node add/edit form it shows a "trimmed version" and a "full version". I don't want to show the trimmed version.
The fix suggested for D6 doesn't work for D7. Any ideas?
1
vote
5
answers
6k
views
ajax form submit multiple times
I have a form which consists of one submit button (Add to cart). I made it submit via AJAX but the problem is that when I press the button the second or third (and so on) times, the submit handler ...
1
vote
2
answers
633
views
What hook gets called at the formation of a form? (hook_form_alter called for adjusting a form)
what hook gets called at the formation of a form.
I'm trying to add some additional mime types to form with id file_entity_add_upload but my hook_form_alter is getting called after these are ...
1
vote
2
answers
4k
views
Building an advanced multicriteria search
I'm kinda new to Drupal and I would like some advises.
I have a Drupal website, with a few nodes (1000 - 5000) of a particular content type, let's say a "House".
This "House" content type has a few ...
1
vote
2
answers
9k
views
How to send email in drupal
I have drupal site in that ,i want to send a email to charities when donor post a donation..,and i want to send a email notification to charities,so how i send email using drupal7
$message = array(
...
1
vote
3
answers
7k
views
How do I pass a value from the url to a custom field in the registration form?
I know variations of this question have been asked but I haven't found any with this specific set of characteristics. Also, the only programming language I know is python. I don't know PHP at all.
I ...
1
vote
2
answers
3k
views
3 Level dependent dropdown. The 3rd list won't update while first one changes
I am trying to create a 3 level dependent dropdown select.
Lv1 Options > Lv2 Options > Lv3 Options.
e.g:
AUDI > Coupé > A5
BMW > SUV > X5
I followed Examples module and this answer to ...
1
vote
1
answer
2k
views
How to disable required fields in form?
I am building a multi-step form. For one of the steps, I have some required fields. When the user goes back, I'm skipping the validation, but it gets hung up on my required fields. Is there a way ...
1
vote
1
answer
423
views
How to render complete page when overriding page--node--add--typename.tpl.php
I'm trying to add more buttons to a custom content type form.
I create a page--node--add--typename.tpl.php where I modify the form then render it:
$form = node_add('answer');
$form['actions']['...
1
vote
0
answers
2k
views
How to wrap managed_file Form API element with custom HTML using #theme_wrappers?
I'm using Drupal 7.23 with no core hacks. I have form element for logo:
'logo' => array(
'#title' => t("Logo"),
'#type' => 'managed_file',
'#description' => t('Allowed extensions: ...
1
vote
1
answer
2k
views
Is there a way to alter a node save confirmation form?
I would like to add a confirmation form that is presented to a user on node update/delete operations triggered through the UI.
Specifically, I would like the form to present more than two choices for ...
1
vote
2
answers
95
views
Extended default form inside block, possible?
Ok. So I have a content type, let's say "My favorite places".
So naturally Drupal has a form to create new "favorite place" at node/add/my-favorite-places which appears as a page. I managed to create ...
1
vote
1
answer
468
views
Why submit button is losing disabled attribute after deletion of uploaded file?
The task is simple: submit button must be enabled only if file is attached to file input.
The form code:
function custom_module_form($form, &$form_state) {
$form['#attributes']['enctype'] = ...
1
vote
1
answer
2k
views
Get node id of saved node
I want a function/hook to be called at a point just when my custom node type is saved, I want to get the generated node id in that function, as I have to perform some operations based on nid.
I know ...
1
vote
1
answer
1k
views
7: How to cache $form[] elements in complex AJAX forms
How is it best to efficently rebuild your form on multiple AJAX requests?
That is how can I cleanly cache individual elements so I don't need to rebuild them?
Using static variables is not an option ...
1
vote
1
answer
453
views
kpr() in my form validation and submit function is not being called
In my form validation and submit functions, kpr() is not being called. Is there a better way to check that I'm in those functions? If kpr() isn't ideal to output my $form_state array, then what is ...
1
vote
2
answers
642
views
How do I create multiple nodes on the same page?
Im on d7. I am trying to create node submission process where I can create multiple nodes on the same submit page and have them all reference a single separate node on the site. any suggestions?
1
vote
1
answer
3k
views
multiple submit handlers
I have the following code:
function corporate_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_login_block':
{
unset($form['links']);
$form['...
1
vote
2
answers
234
views
Get Div's Text in Drupal Forms API
I have this code below:
$form['id']['mypreview_modal'] = array(
'#type' => 'item',
'#markup' =>
'<div id="mypreview_modal" title="ID Preview">12345</div>'
);
$...
1
vote
4
answers
2k
views
How to unset fieldset in hook_form_alter?
I want to unset a fieldset programmatically which is available in the content type. I tried to unset like this in hook_form_alter,
unset($form['field_first_deposit']);
But it doesn't work, where as ...
1
vote
2
answers
2k
views
Results of autocomplete field in form depending on another field - Drupal 7
I have an autocomplete field in a Drupal form made with Form API. It works great, suggesting the data from a db_query.
However, I would like to alter this db_query depending on the selection made in ...
1
vote
3
answers
8k
views
Using Drupal Commerce, how do you render the "add to cart" button?
I have created a custom node.tpl.php file for the product_display content type. I have everything worked out except I have no ideal how to isolate the "add to cart" button, actually the "add to cart" ...
1
vote
2
answers
2k
views
Can't use file field in custom form - gives AJAX errors
I'm building my own form for editing certain fields on a node type, and I'm using field_attach_form() to add the fields from that node type to my form.
Use field_attach_form() to get the fields added ...
1
vote
1
answer
2k
views
How to style a programmatically created page with a template?
I'm struggling with understanding theming pages with templates. I'm stuck with creating a new template for a programmatically created page. I have a module that shows a download page for a file. The ...
1
vote
1
answer
186
views
Limit the reviews on "Product" content type
I want to limit the users' review of my "Product" content type to only one, and I tried to implement a code from this link in Drupal 7 as a simple module named "review_limit." I saw this module in my ...
0
votes
2
answers
4k
views
how to ignore the validation of hidden form fields in the user registration form?
I am having a problem regarding the validation of the hidden fields.
I have some some fields that are hidden and only visible if a specific field is selected.
And I marked those those hidden fields ...
0
votes
1
answer
356
views
Processing forms together for a tree of related entities
I have EntityA which has one or more EntityB's which have one or more EntityC's. EntityB references values of EntityA and EntityC references values of EntityB. My current plan is to have an id field ...
0
votes
1
answer
1k
views
how to hide text format tips for text field in a module, not theme?
I need to hide the text format tips for body field, depending on user role, in a module. After some research, I found this kind of code:
function mymodule_form_node_form_alter(&$form, &$...
0
votes
1
answer
144
views
How do I set up user's "Favorite Tags" and "Ignored Tags" tag subscriptions?
This website shows user-specific "Favorite Tags" and "Ignored Tags" listing tags the user subscribed to. Based on these subscription lists, content is being sorted in "views".
How do I let the users ...
0
votes
3
answers
2k
views
How to set #default_value for radio button on Ajax Callback?
I've a form having a radios and 'select list with Ajax callback event'. When user changed selection from the select box, I tried to set the default_value for radio button. but it doesn't work.
In the ...
0
votes
2
answers
4k
views
In form alter what is the different way of hiding fields and what is the difference between them?
I am currently using the following code to hide the fields in the form
1. $form['field_name']['#access'] = FALSE;
2. hide($form['picture']);
3. unset($form['picture']);
4. $form['account']['mail']...
0
votes
3
answers
3k
views
Managed file validation on first upload only
In D7,I have new_form with a managed_file field to allow my user to upload documents to public://. I'm trying to prevent my user from uploading a document if the file name they are trying to upload ...
0
votes
1
answer
70
views
How to build a block on form submission?
I know how to build a block using these functions :
hook_block_info()
hook_block_configure()
hook_block_save()
hook_block_view()
But on a form submission a few information is saved into DB and based ...
0
votes
1
answer
4k
views
How do I change submit URL for exposed search filter?
I've created view using Search API Views with two different displays.
First Page display (by_terms) and with the following options:
Page settings: Path:/taxonomy/term/%
Contextual filters: Category: ...
0
votes
1
answer
434
views
How do I programmatically insert the entity ID?
I have added extra fields on the drupal 7 user registration form and created a module with a hook_form_alter function so that i can alter one field in the registration form.
in the same file i also ...
0
votes
1
answer
213
views
Custom submit handler is also called when deleting a node
So these are my functions:
function mycustom_form_alter(&$form, &$form_state, $form_id) {
$form['actions']['submit']['#submit'][] = 'b2share_form_submit';
return $form;
}
I can also ...
0
votes
0
answers
1k
views
Ajax not working for themed form
I have a form for which I want to theme with a template file, and I also need to use ajax in it. But I get this error messages in the log and ajax doesn't work :
message 1
Invalid form POST data.
...
0
votes
1
answer
2k
views
Making text fields autocomplete in views exposed filters
I want to make a text field auto complete in a views exposed form. I tried using the following code but nothing happens(I don't see that blue icon in the text field):
<?php
function nk_menu() {
...