Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top