Hey, everyone!
I've done my homework on this one, but I'm kind of stumped...
I'm working on porting the Spam module to D6 (issue here... help us test it!!!).
One message from the deadwood module is :
/* TODO The 'op' element in the form values is deprecated.
Each button can have #validate and #submit functions associated with it.
Thus, there should be one button that submits the form and which invokes
the normal form_id_validate and form_id_submit handlers. Any additional
buttons which need to invoke different validate or submit functionality
should have button-specific functions. */
In this situation, the code in question is located in the function that handles the module settings form. The form is generated using the standard API, including a call to system_settings_form(), which is normal for module settings pages.
system_settings_form() places two buttons on the form: "Save configuration" and "Reset to defaults".
In the Spam module's _submit() function, "op" was used to determine which of these two buttons was pushed in order to execute additional, appropriate code.
The TODO message (and the information found here) implies that "op" should not be used at all, calling it deprecated. A cursory look at core functions, however, such as system_settings_form_submit() demonstrates that Drupal core itself uses the "op" variable rather than the advised stand-alone #submit function.
There is no separate #submit function defined for the "Reset to defaults" button by the system_settings_form(), so is it OK to use the op element despite the warnings of it being deprecated? If not, then what action is advisable?
Comments
I have exactly the same question
I've spent two hours trying to figure this out and I'm getting no where. In fact, I'm not even completely sure what the module code with 'op' in it is doing, since I didn't write it (I took over the module from someone else). If I can't figure out what it's doing, I have no possible chance of fixing it. Here's the code (from phpFreeChat):
What are these 'if' statements testing, and how am I supposed to rewrite them for Drupal 6?
Someone please answer.