Browse files

blog MDL-23393 - Tidy up preferences form

Make form display set value and use mforms type checking
  • Loading branch information...
1 parent 46f4c39 commit 926814896641b1fc0294f4b7b4a047e84329f884 @danpoltawski danpoltawski committed Jan 9, 2011
Showing with 4 additions and 1 deletion.
  1. +1 −0 blog/preferences.php
  2. +3 −1 blog/preferences_form.php
View
1 blog/preferences.php
@@ -73,6 +73,7 @@
/// 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;
View
4 blog/preferences_form.php
@@ -39,7 +39,9 @@ public function definition() {
$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();
}

0 comments on commit 9268148

Please sign in to comment.