blog MDL-23393 - Tidy up preferences form
authorDan Poltawski <dan.poltawski@luns.net.uk>
Sun, 9 Jan 2011 18:01:55 +0000 (18:01 +0000)
committerDan Poltawski <dan.poltawski@luns.net.uk>
Sun, 9 Jan 2011 18:03:58 +0000 (18:03 +0000)
Make form display set value and use mforms type checking

blog/preferences.php
blog/preferences_form.php

index 366beda..472ee30 100755 (executable)
@@ -73,6 +73,7 @@ require_capability('moodle/blog:view', $context);
 /// If data submitted, then process and store.
 
 $mform = new blog_preferences_form('preferences.php');
 /// If data submitted, then process and store.
 
 $mform = new blog_preferences_form('preferences.php');
+$mform->set_data(array('pagesize' => get_user_preferences('blogpagesize')));
 
 if (!$mform->is_cancelled() && $data = $mform->get_data()) {
     $pagesize = $data->pagesize;
 
 if (!$mform->is_cancelled() && $data = $mform->get_data()) {
     $pagesize = $data->pagesize;
index a1fff64..d5c5005 100644 (file)
@@ -39,7 +39,9 @@ class blog_preferences_form extends moodleform {
         $strpagesize = get_string('pagesize', 'blog');
 
         $mform->addElement('text', 'pagesize', $strpagesize);
         $strpagesize = get_string('pagesize', 'blog');
 
         $mform->addElement('text', 'pagesize', $strpagesize);
-        $mform->setDefault('pagesize', get_user_preferences('pagesize'));
+        $mform->setType('pagesize', PARAM_INT);
+        $mform->addRule('pagesize', null, 'numeric', null, 'client');
+        $mform->setDefault('pagesize', 10);
 
         $this->add_action_buttons();
     }
 
         $this->add_action_buttons();
     }