Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
10 Nov 2008 at 17:10 UTC
Updated:
25 Nov 2013 at 17:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidWe could use to expand this documentation now in D7, the backport.
Comment #2
drewish commentedMarking #1189516: system_settings_form does not really explain what it does as a duplicate of this. It has further documentation.
Comment #3
joachim commentedHere is my comment from that issue:
system_settings_form() is a really nifty helper for module admin settings forms that allow the user to edit variables (ie the things you variable_get().
You call it with your $form array at the end of your form builder. It does this:
- adds standard buttons for saving & resetting
- adds a submit handler which saves $form['foo'] as variable 'foo', ie does variable_set('foo', form values)
- (D7 and up IIRC) populates the $form's default values with the results of variable_get().
When you should use it:
- your settings form saves variables
- your settings form saves variables + other things
If you need to save other things, or you need to massage the form values before they are saved to variables, you can add in your own submit handler to run before the system one and:
- unset form values you don't want to be saved as variables (eg, ones you are saving yourself in a table)
- massage form values you want to be saved in a different format (eg, arrays of things).
Comment #4
gddsystem_settings_form() is being removed in D8 (see #1696224: Remove system_settings_form()) so I'm marking this wont fix.
Comment #5
joachim commentedWould be nice to have this in D7 though.
Comment #6
jhodgdon+1 on the idea of taking the patch above, making it conform to our documentation standards, and getting it into D7 and possibly D6. Since there was a patch but it needs work, changing status appropriately.
Standards needing attention:
- first line of function doc (verb, blank line following)
- all functions mentioned end in ()
Also I think the docs need rewriting a bit, since they're inconsistent as to what happens directly in this function and what happens in the submit (probably what the submit does should be documented on the submit, and referenced from system_settings_form()?).
Comment #7
chriscohen commentedWell, I submitted the patch more as a starting point for someone with more knowledge to be able to get this committed. As it's been 1,627 days since I posted this, I'd say mission failed!
However, would still be good to get something along these lines put into D7, hopefully fairly soon.
Comment #8
jhodgdonchriscohen: thanks for your original patch! It would be great if you wanted to clean it up so we could get it committed. :) If not, I'm at least tagging it "novice" so that maybe someone will pick it up.
Comment #9
diego21 commentedThis is my first patch, I hope it's ok.
Comment #10
jhodgdonThanks for the new patch, and welcome to Drupal Core contributing!
This still needs some work:
a) We have a standard way to document form submit functions:
https://drupal.org/node/1354#forms
b) All of the documentation needs some grammar fixes, rewriting for clarity, and proofreading.
c) For the system_settings_form() function, the first line should start with "Adds" not "Add".
d) In the first paragraph of the system_settings_form() added documentation, it says it "calls" the submit handler. That is not true. It just sets up the submit handler. It also says that the submit handler "creates" a submit handler, and that is not very good terminology.
e) Please do not use "eg". It is almost always misused and misunderstood, and almost always (as here), punctuated incorrectly. Please use "for example" instead.
Comment #11
diego21 commentedThanks for your help!! It's a pleasure for me to help the community. I really want to learn as much as possible. Please, if the patch is not correct yet, let me know. I'd like to do it well.
Comment #12
jhodgdonMuch better, thanks! It still needs a bit of work... I think the general idea is good, but the wording is very conversational and sounds more like marketing rather than documentation. We just want to document what the function *does*, not try to induce someone to want to call the function.
So how about changing the first line to "Sets up a form to save information automatically." Then the next part could say something like:
Then we can probably omit most of the documentation that is in the submission handler and the main function. Keep in mind that most people will not actually be clicking through to read the submit function documentation, so anything important for the user to know should be in the main system_settings_form() documentation, not in the submit handler docs. And I just don't think we need to go into as much detail as what is there -- this is reference documentation, not a tutorial.
Thoughts?
Comment #13
diego21 commentedI really appreciate your patience. I cleaned up the submission handler documentation to adapt it what you said in #10 comment, a) section. If I acted wrong, tell me please. Thanks so much.
Comment #14
jhodgdonLooks good to me! I guess I wrote the text, so it should. :) I'll leave this for a few days in case anyone else has a comment about the text.
Comment #16
jhodgdonThat was odd. For some reason, a notification about a very old patch was just generated.
Comment #17
jhodgdonThanks again everyone! Committed to 7.x.
Comment #18
diego21 commentedIs it really committed jhodgdon? I can't find it. It was a pleasure! :D
Comment #19
jhodgdonI believe so. http://drupalcode.org/project/drupal.git/commitdiff/ae919dbaa8c7faf15096...
There may be problems with tar/zip downloads on drupal.org right now... there have been some recently... but it is there in git.