Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By n3_nash on
/* implementation of function intelligentsystem_menu(){
....
}*/
function intelligent_system_home_output(){
header('Content-type: text/plain; charset=UTF-8');
header('Content-Disposition: inline');
$content = intelligent_system_home_nameform();
return $content;
}
function intelligent_system_home_nameform(){
$form['title'] = array(
'#type' => 'fieldset',
'#title' => t('Enter the information :'),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name :'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
$form['#submit'] = 'intelligent_system_home_nameform_submit';
return $form;
}
function intelligent_system_home_nameform_submit($form, &$form_state) {
drupal_set_message(t('The data is being Analyzed!!'));
}
I have tried calling a user defined function also rather than the above mentioned _submit..but nothing is working..drupal 6 used to support the above...but drupal 7 doesnt seem to..have checked out many forums..but there seems to be no solution..pls help..
Comments
Not sure what the
Not sure what the line
is doing in your code. Any form attributes must be declared as arrays, here you are declaring it as a string. Take it out and see if it helps.
What Bagz means is you can
What Bagz means is you can fix this by changing
$form['#submit'] = 'intelligent_system_home_nameform_submit';
to
$form['#submit'][] = 'intelligent_system_home_nameform_submit';
Notice the empty brackets at the end of the $form['#submit'][]. This will append your new submit hook to the end of the array, instead of overwriting it with a string.
Form submit not working :(
hey did u find any solution.
I am migrating my module from D6 to D7.
I am also facing the the same problem.
I have given:
$form['#submit'] = array('intelligent_system_home_nameform_submit') ;
Let me know what worked for you.
This worked for
This worked for me:
$form['#submit'][] = 'charity_addRole';
Later:
By writing
By writing this:
$form['#submit'] = array('intelligent_system_home_nameform_submit') ;
you could be potentially overwriting other modules addition to the '#submit' array, that means their callbacks won't be fired anymore...it's better to add to the array instead:
$form['#submit'][] = 'intelligent_system_home_nameform_submit';
Try this will works..
Hey try this below code:
$form['#submit'] [] = 'intellegent_system_home_nameform_submit';
check this above code..now
submit button needs functionality.
For me, I added another field to the form button:
you have
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
I have:
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#submit' => array('reset_your_pc'),
);
Working code for Form submit handler in Drupal 7
Submit Handler for other buttons in CCK - Drupal 7
Also having this problem
I am also having this problem; I just don't see what I am doing wrong. I've been a D6 programmer for years, and after reading numerous articles for D7, I can't figure it out. Here's my super-simple code:
Can anyone tell me what I am doing wrong? I never get into that function. And I have confirmed that hook_form_alter is indeed attaching that submit handler to the correct form ;)
Thanks!
And of course I figure out my
And of course I figure out my problem literally seconds after posting this. It never fails, does it?
Anyway, I WAS getting into that function, but I wasn't seeing the message. When I did a watchdog() call instead, I saw it show up in the database!
I logged out and back in, and suddenly the message is now showing up. I guess something was screwy with my session?
Anyway, sorry-- the code I posted DOES work.
Richard
Form Submit Problem
HI!
How Can I Submit My Form In Drupal
I had the same problem, I was
I had the same problem, I was wondering why my submit handler was not firing.
My usual helpers
dpm('hello');
andvar_dump('hello');
were not showing up.Then tried
dd('hello');
, and sure enough it showed up in/tmp/drupal_debug.txt
For anyone coming across this -
dd()
ordrupal_debug()
should work as long as you have devel module enabled.I had empty hidden form field
$is_edit is boolean, so when it's TRUE, #default_value gets empty string.
And because it was hidden, I could not see the error.
Proper way:
This caught me out too...
I struggled to get this working too in a .module file. You have to have both the button and the '#submit' part, and then define the redirect in the submit function.
The documentation lead me to believe that the _submit function would be automatically picked up, but this didn't seem to be the case:
Perhaps there was something else going on in my form breaking it though.
I figured this out after
I figured this out after looking at the source code of entity forms.
Instead of putting the callback under #submit, put it under actions.
So instead of this:
$form["#submit"][] = "tc_test";
Try this:
$form['actions']['submit']["#submit"][] = "tc_test";
It worked for me, hopefully is saves someone else some headache.
This works for Entity Forms
I had the same problem only on an entity form and this solved it.
Form Submit handler not working in Drupal 7
If you are rendering your form using form--anyformname.tpl.php template file then make sure in that template file you are rendering these three thing at the end:
print render($form['form_id']);
print render($form['form_build_id']);
print render($form['form_token']);
Don't forget form tokens!
Hey guys!
@manish9a9's answer was totally the case with me.
Make sure that if you're using a template file to theme your form, you don't forget to place:
anywhere on your template file.
This will render the missing items (usually the tokens) to your form and make sure it gets properly processed/executed.
Thank you and good luck! ;)
--
Heitor Althmann
Drupal Developer
Life Saver!!!
I have spend days to get to this. Thanks a lot.
Batch processing
If one of the submit handlers performs a batch operation, all subsequent submit handlers will not be called anymore.