4

I should write a simple module (Not use WebForms) that make a form for get data. But my the elements of my form didn't show. I use the drupal 6.0 doc but i don't know what is wrong!

this is the link of my source code.

I get the error msg: warning: Missing argument 2 for registration_register_form() in /var/www/drupal/sites/all/modules/registeration/registration.module on line 29.

But i write the correct arguments.

AKS
  • 4,618
  • 2
  • 29
  • 48
Good man
  • 396
  • 4
  • 12

1 Answers1

1

You do not need to pass the $form and $form_state in most* forms.

Try this:

function registration_register_form(){

instead of:

function registration_register_form($form, &$form_state){

Background: drupal_get_form passes any given parameters to registration_register_form() but in registration_all(), you don't pass any extra arguments. (Just the callback of the form function).

Note that you still need to pass $form and $form_state in submit function as registration_register_form_submit() uses $form_state's data.

*most cases: if your form is a multistep form and the form changes on $form_state variable's values, that's a good use case that you do need to pass $form and $form_state to registration_register_form()

Update After checking your code, I found many errors. See new revision: http://pastebin.com/VNa3veFR (unlisted) I have corrected most of the problems I could note. See inline comments and comment blocks above function names.

AKS
  • 4,618
  • 2
  • 29
  • 48
  • my problem is solved but,just another error when i leave the id field empty, i get this error: An error occurred. /drupal/?q=registration/js_idcheck. I changed js_idcheck function for empty id field. the new code is here [link]http://pastebin.com/2cSqZx10 – Good man Oct 19 '12 at 19:11
  • When i enter some number in ID field o get this error: An HTTP error 500 occurred./drupal/?q=registration/js_idcheck when i submit my form i get the 500 HTTP error in back ground. I think the $form_state in js_idcheck id not true,i use the $_POST['id'] but the result didn't chenge. – Good man Oct 19 '12 at 20:53
  • 1
    http://pastebin.com/nuusAv9F However, I would recommend reading a Drupal book with some API information before proceeding to serious level Drupal work. Your code has some sql injection possibilities and not following Drupal coding standards. You will lean them by the time, but it's good to start using them at the earliest you can do. If you are not sure about any function, just refer the php.net manual and/or api.drupal.org – AKS Oct 19 '12 at 20:54
  • 1
    may be you can read this great article about #ahah. Sory, $form_state is not avail. to this function. my bad. http://randyfay.com/ahah – AKS Oct 19 '12 at 21:30