In Drupal 7 hook_block_configure and hook_block_save provide a method to modify a blocks settings and save these values.

But how would I carry out validation on the form before saving the values?

有帮助吗?

解决方案

As found here when configuring your form element you should add an '#element_validate' that points to a custom validation function of the element. You can find more information in the Form Api here

其他提示

If you wish to add validation for the whole form, this is not really possible. The best way I have managed to implement myself is to add a custom function to the code with $edit as a parameter with Boolean as a return value. Then call the function in the hook_block_save() before saving data in order to perform the extra checks. Works fine with the only exception that it will not highlight in red values that are incorrect in the form.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top