* Implementation of hook_form_alter().
*/
function context_form_alter(&$form, $form_state, $form_id) {
- if ($form['#id'] === 'node-form' && arg(0) != 'admin') { // Prevent this from firing on admin pages... damn form driven apis...
+ // Prevent this from firing on admin pages... damn form driven apis...
+ if ($form['#id'] === 'node-form' && arg(0) != 'admin') {
context_node_condition($form['#node'], 'form');
+ $form['#validate'][] = 'context_form_alter_node_validate';
}
if ($form_id == 'system_modules') {
context_invalidate_cache();
}
/**
+ * Node form validation callback.
+ *
+ * Set context also on validate, otherwise forms that don't validate drop out
+ * of context.
+ */
+function context_form_alter_node_validate($form, &$form_state) {
+ context_node_condition($form['#node'], 'form');
+}
+
+/**
* Implementation of hook_form_alter() for comment_form.
*/
function context_form_comment_form_alter(&$form, $form_state) {