Search code examples
phpdrupaldrupal-6ahah

drupal 6 module programming semantic error


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.


Solution

  • 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.