This is not a good way to save the values: in the validation callback.
You probably did this, to make sure the block-module (or another) did not already call the drupal_goto(), but this method is error-prone:
* If validation of another value on the block fails, your values are saved nonetheless.
* If your insert/update/delete fails, you may end up with a broken database: your content is not saved, but other block-setting may, or may not be saved. result is unknown and hence "dangerous".
What is your reason for not using a submit callback?
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 709110-cleanup-odd-validation-save-logic.patch | 2.43 KB | neclimdul |
| #5 | 0002-Cleanup-odd-validation-save-logic.patch | 2.76 KB | neclimdul |
| #2 | 709110_split_up_validation.patch | 3.74 KB | neclimdul |
Comments
Comment #1
ngmaloney commentedI'll look into this and work on a patch.
Comment #2
neclimdulHere's a patch. Did a little additional cleanup around the validation callback as well to make it more resilient.
Comment #3
ngmaloney commentedneclimdul - Thank you for taking the time to do this. I'll roll it into CVS ASAP.
Comment #4
ngmaloney commentedneclimdul - I tested the patch and it is throwing the following errors:
warning: Wrong parameter count for array_search() in drupal-6.16/sites/all/modules/block_titlelink-HEAD/block_titlelink.module on line 36.
warning: Wrong parameter count for array_search() in drupal-6.16/sites/all/modules/block_titlelink-HEAD/block_titlelink.module on line 41.
Running on php 5.2.6
Comment #5
neclimdulReroll with fix. Built on top of #1072800: Cleanup documentation to be closer to core standards in case patch doesn't apply cleanly.
Comment #6
neclimdulReroll
Comment #7
neclimdulThis has been pretty well tested by users on my site but for the sake of not marking your own patch RTBC I'll mark this NR
Comment #8
adammaloneAltered in the 6.x-2.x version to save values in form_submit.
Comment #9
adammalone