Henry Lyne (henrylyne) wrote in changelog,
Henry Lyne
henrylyne
changelog

[livejournal] r15282: LJSUP-4428 Add new hook for checking fie...

Committer: henrylyne
LJSUP-4428 Add new hook for checking fields.
Remember the fields as they were submitted, in case an error is thrown.

U   trunk/htdocs/manage/sms/index.bml
Modified: trunk/htdocs/manage/sms/index.bml
===================================================================
--- trunk/htdocs/manage/sms/index.bml	2009-06-11 08:59:18 UTC (rev 15281)
+++ trunk/htdocs/manage/sms/index.bml	2009-06-11 12:08:06 UTC (rev 15282)
@@ -30,9 +30,15 @@
 
     LJ::run_hook('sms_bml_init', $u);
 
-    # process changes
+    # Before handling any of the fields do basic checks
     if (LJ::did_post()) {
+        LJ::run_hook('sms_bml_post_check', u => $u,
+                     errors => \@errors, POST => \%POST);
+    }
 
+    # process changes
+    if (LJ::did_post() && !@errors) {
+
         # sms notification checkbox
         if ($POST{notif} eq 'on') {
             $u->set_prop('sms_post_notify', 'SMS');
@@ -155,11 +161,11 @@
             push @carriers, ($k, $v);
         }
 
-        $carrier = LJ::html_select({noescape => 1, name => 'carrier', selected => $u->prop('sms_carrier')},
+        $carrier = LJ::html_select({noescape => 1, name => 'carrier', selected => $u->prop('sms_carrier') || $POST{carrier}},
                                    ('', '(Select Carrier)'), @carriers);
     }
 
-    my $fgroup = LJ::html_select({name => 'fgroup', selected => $u->prop('sms_friend_group')},
+    my $fgroup = LJ::html_select({name => 'fgroup', selected => $u->prop('sms_friend_group') || $POST{fgroup}},
                                 ('', '(All Friends)'), map { $_, $_ } map { $_->{groupname} } @fgroups);
 
     my $body = '';
@@ -170,7 +176,7 @@
 
     my $notif = LJ::html_check({
         name     => "notif",
-        selected => ($u->prop('sms_post_notify') eq 'SMS'),
+        selected => ($u->prop('sms_post_notify') eq 'SMS' || $POST{notif}),
         id       => "notif",
         label    => "Notify me of comments to posts made using $LJ::SMS_TITLE by text message",
     });

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments