]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po: back to the cansave hook, as the form validation is not sufficient
authorintrigeri <intrigeri@boum.org>
Fri, 2 Jan 2009 17:51:32 +0000 (18:51 +0100)
committerintrigeri <intrigeri@boum.org>
Fri, 2 Jan 2009 17:51:32 +0000 (18:51 +0100)
Form validation works, but after trying to save invalid PO content, the user is
brought back to the page he/she was editing, without any single clue to explain
why it was not saved. The dedicated cansave hook is thus necessary.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm

index 01912f813d2c384c63aea704060c90e29f4e3e65..b51bc34f7e9cd753cf1db9ac6744c5f5d6b16957 100644 (file)
@@ -39,7 +39,7 @@ sub import {
        hook(type => "rename", id => "po", call => \&renamepages, first => 1);
        hook(type => "delete", id => "po", call => \&mydelete);
        hook(type => "change", id => "po", call => \&change);
        hook(type => "rename", id => "po", call => \&renamepages, first => 1);
        hook(type => "delete", id => "po", call => \&mydelete);
        hook(type => "change", id => "po", call => \&change);
-       hook(type => "cansave", id => "po", call => \&cansave);
+       hook(type => "cansave", id => "po", call => \&cansave);
        hook(type => "canremove", id => "po", call => \&canremove);
        hook(type => "canrename", id => "po", call => \&canrename);
        hook(type => "editcontent", id => "po", call => \&editcontent);
        hook(type => "canremove", id => "po", call => \&canremove);
        hook(type => "canrename", id => "po", call => \&canrename);
        hook(type => "editcontent", id => "po", call => \&editcontent);
@@ -503,15 +503,6 @@ sub formbuilder (@) {
                        }
                }
        }
                        }
                }
        }
-
-       # Prevent invalid PO content to be saved.
-       # This cannot be done in the formbuilder_setup hook as the editpage plugin
-       # unconditionally sets the editcontent field's validate code later.
-       elsif ($form->field("do") eq "edit") {
-               if (istranslation($form->field("page"))) {
-                       $form->field(name => "editcontent", validate => \&isvalidpo);
-               }
-       }
 }
 
 # ,----
 }
 
 # ,----