Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
ajax system
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Jun 2012 at 19:20 UTC
Updated:
23 Oct 2013 at 10:00 UTC
Jump to comment: Most recent
Comments
Comment #1
anouAn answer a year later....
For what I found, it will be possible in D8. Didn't find a way in D7. Check this post.
Comment #2
dianikol commentedI have found the solution a year back, I need to use hook_form_alter to access the form in block and to use ajax
Comment #3
DHL commentedHi dianikol,
If you use hook_form_alter to create the form, how to pass it to hook_block_configure ?
Comment #4
anouHello DHL,
You do not create the form with hook_form_alter() but within hook_block_configure() and alter it with hook_form_alter()
And by the way, thanks dianikol for the answer ;-)
Comment #5
DHL commentedHello anou,
Do you mean place the hook_form_alter inside hook_block_configure like below ?
Comment #6
anouNope. Not at all.
You must have the 2 functions separate.
Hope this will help you to achieve your goal.
Comment #7
DHL commentedI have a question about the form_id
No matter which block, I found that their form_id are all the same - "block_admin_configure"
About the code you suggest, I try them before and there are 2 problem.
First, its not work.
Second, those forms I defined in hook_form_alter appear below the "Save block" button at the block configure page. Since I mention that all block configure page has the same form_id. So, those forms appear below the "Save block" button in all different block configure page.
Comment #8
anouFor the order, you must study this : weight
Second: the code does work, believe me :-)
Third: you must install the Devel module and then you'll be able to print the $form variable and find maybe other values to narrow the lack of precision you have with $form_id for blocks...
Comment #9
DHL commentedI manage to make Ajax work in block configure page. But it not look good.
Please download the demo module I made from the link below
demo module - Ajax test
This code in this module was copy from the D7 "Example" module. And use one of it demo - Simplest AJAX Example
https://drupal.org/project/examples
Inside the zip file include the screen capture of the problem I facing.
1. Duplicate form display in block configure page.
2. Same form_id among all different block configure page.
Comment #10
dianikol commentedYou must use in
hook_form_alternot the form_id but the block dellta to narrow down the current form.i.e.
I'm not sure $form['delta'] exists in the $form variable. Just to get the idea
Comment #11
DHL commentedTo find the module or delta name, I have another method
This successfully make the form appear in the target block configure page only.
But at the same time the Ajax not work anymore. I don't know why.
Comment #12
dianikol commentedYou should check the delta in the $form array variable. It is safer.
Post your whole code to check it out