-1

I am learning to add a checkbox to registration form about agreeing to terms of use, found in modules/system/system.api.php, line 1708

I found an information here in modifying the hook_form_FORM_ID_alter here How to display the values after submit in drupal 7

I modified the file modules/system/system.api.php as instructed (FORM_ID) changed to my form id, but nothing happens.

Could anyone provide a direction how to do that?

2
  • 1
    If you are asking about code you wrote, post the code you are using, or the part of code relevant to your question.
    – Mołot
    Oct 1 '14 at 9:10
  • 1
    You should not edit modules/system/system.api.php. You have completely misunderstood how the form api works, and need to re-read how it works.
    – Letharion
    Oct 19 '14 at 14:21
1

Dump! You did a big mistake! Never modify the core! You can use hook system

3
  • I don't know about that. If I modify the function, where I have to save the function. I am a really a beginner. Oct 1 '14 at 9:36
  • 1
    You don't modify the function @WaluyoAdiSiswanto, you implement a hook. We can't teach you the very basics here (too broad for this format), check out the Module Developer's guide, and this explanation of what hooks are to get started. Drupal has a steep learning curve, I'd also highly recommend investing in a book to get you going.
    – Clive
    Oct 1 '14 at 9:43
  • I really want to learn it. Can you recommend the book you have mentioned, so I can purchase it or borrow from the library if available. Oct 20 '14 at 12:41
1

.api.php files are files that give developers information on the function and hooks that a module makes available to others.

So modules/system/system.api.php is just developer information on Drupal system module API type functions.

It is basically just documentation so you editing it will do nothing (except for then making that documentation incorrect, which is bad if anyone else wants to use it).

To properly implement a hook you need to create a custom module that implements that hook.

For example you might create a module called customregistration and then you might implement this:

/**
 * Implements hook_form_alter().
 */
function customregistration_form_alter(&$form, &$form_state, $form_id) {
  // Put your code here to alter the form.
}

For some form alter examples see Hook snippets: hook_form_alter.

It would be also very much worth your while to do some basic learning about writing drupal modules.

There are lots of good affordable textbooks and there are also pages like the Module developer's guide (and all it's child pages) and modules like Examples for Developers that all have useful information.

There is a lot of information but cutting corners on initial learning will possibly come back to haunt you in future.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.