Skip to main content
added 139 characters in body
Source Link
stefgosselin
  • 3k
  • 1
  • 25
  • 36

Basically Ek Kosmos has the basic idea. The easiest would be to create a small custom module, this has the advantage of isolating the feature you want to build, and remember the #1 rule, you really never want to hack anything in core, unless you really cannot avoid it.

Once you have your .info file setup in a folder and .module file ready to go as indicated in the many how-to's on the subject, you leverage the power of hook_form_alter by writing a function named your-module-name _form_alter in your module file and you know that function will be called.

You would haveprobably need a switch statement dependent onin the form id, and in that if)alter to perform specific actions depending on the form id, you

You would probably need to addtry adding an attribute (#validate) that adds a function call on the form array, that would point tobeing a function name of your own custom validation function.

SOmethingSomething like: // #validate adds callback to custom validator. $validators = $form['#validate'][]; // Save existing validation calls. // Not clear in docs, but this is important!

   // #validate adds callback to custom validator.
   $validators = $form['#validate'][]; // Save existing validation calls. 
   //  Not clear in docs, but this is important!
    
  // In your case, you may want to add a method callback with this attribute.                                   
  $form['#validate'][] = $validators . ' _custom_validate';
  

Of course, in your validation function you could log errors, redirect, assign error messages or notifications.

Do read the form api and download the form examples.

If you need help and examples galore, download contrib modules and see how others tackeled the beast, or post questions here as you go along.

HAppyHappy conding, good-luck.

Basically Ek Kosmos has the basic idea. The easiest would be to create a small custom module, this has the advantage of isolating the feature you want to build, and remember the #1 rule, you really never want to hack anything in core, unless you really cannot avoid it.

Once you have your .info file setup in a folder and .module file ready to go as indicated in the many how-to's on the subject, you leverage the power of hook_form_alter by writing a function named your-module-name _form_alter.

You would have a switch statement dependent on the form id, and in that if, you would probably need to add an attribute that adds a function call on the form array, that would point to your own custom validation function.

SOmething like: // #validate adds callback to custom validator. $validators = $form['#validate'][]; // Save existing validation calls. // Not clear in docs, but this is important!

  // In your case, you may want to add a method callback with this attribute.                                   
  $form['#validate'][] = $validators . ' _custom_validate';
  

Of course, in your validation function you could log errors, redirect, assign error messages or notifications.

Do read the form api and download the form examples.

If you need help and examples galore, download contrib modules and see how others tackeled the beast, or post questions here as you go along.

HAppy conding, good-luck.

Basically Ek Kosmos has the basic idea. The easiest would be to create a small custom module, this has the advantage of isolating the feature you want to build, and remember the #1 rule, you really never want to hack anything in core, unless you really cannot avoid it.

Once you have your .info file setup in a folder and .module file ready to go as indicated in the many how-to's on the subject, you leverage the power of hook_form_alter by writing a function named your-module-name _form_alter in your module file and you know that function will be called.

You would probably need a switch statement dependent in the form)alter to perform specific actions depending on the form id,

You would probably need to try adding an attribute (#validate) that adds a function call on the form array, being a function name of your own custom validation function.

Something like:

   // #validate adds callback to custom validator.
   $validators = $form['#validate'][]; // Save existing validation calls. 
   //  Not clear in docs, but this is important!
    
  // In your case, you may want to add a method callback with this attribute.                                   
  $form['#validate'][] = $validators . ' _custom_validate';
  

Of course, in your validation function you could log errors, redirect, assign error messages or notifications.

Do read the form api and download the form examples.

If you need help and examples galore, download contrib modules and see how others tackeled the beast, or post questions here as you go along.

Happy conding, good-luck.

Source Link
stefgosselin
  • 3k
  • 1
  • 25
  • 36

Basically Ek Kosmos has the basic idea. The easiest would be to create a small custom module, this has the advantage of isolating the feature you want to build, and remember the #1 rule, you really never want to hack anything in core, unless you really cannot avoid it.

Once you have your .info file setup in a folder and .module file ready to go as indicated in the many how-to's on the subject, you leverage the power of hook_form_alter by writing a function named your-module-name _form_alter.

You would have a switch statement dependent on the form id, and in that if, you would probably need to add an attribute that adds a function call on the form array, that would point to your own custom validation function.

SOmething like: // #validate adds callback to custom validator. $validators = $form['#validate'][]; // Save existing validation calls. // Not clear in docs, but this is important!

  // In your case, you may want to add a method callback with this attribute.                                   
  $form['#validate'][] = $validators . ' _custom_validate';
  

Of course, in your validation function you could log errors, redirect, assign error messages or notifications.

Do read the form api and download the form examples.

If you need help and examples galore, download contrib modules and see how others tackeled the beast, or post questions here as you go along.

HAppy conding, good-luck.