From 4610fc8e7f32f1a582b5f6c9c25714151b9a2967 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 16 Nov 2008 07:51:42 +0000 Subject: Create Forge::add_rules_from() which pulls validation rules from the model and associates them with the form. This replaces the various _add_validation_rules() functions in the user and comment modules. Move user edit form into user helper for consistency with the comment module. Implement missing _form method in the user controller. --- modules/user/helpers/user.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'modules/user/helpers') diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index aaf16299..8ad2709f 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -19,13 +19,28 @@ */ /** - * This helper provides a common around the user management functions. - * + * This helper provides a common around the user management functions. + * * @author Tim Almdal * */ class user { + /** + * Return the form for creating / modifying users. + */ + public static function get_edit_form($user) { + $form = new Forge(url::site("user/{$user->id}"), "", "post", array("id" => "gUserForm")); + $group = $form->group(_("User Info")); + $group->input("name") ->label(_("Name")) ->id("gName") ->value($user->name); + $group->input("display_name") ->label(_("Display Name")) ->id("gDisplayName") ->value($user->display_name); + $group->password("password") ->label(_("Password")) ->id("gPassword"); + $group->input("email") ->label(_("Email")) ->id("gEmail") ->value($user->email); + $group->submit(_("Modify")); + $form->add_rules_from($user); + return $form; + } + /** * Is the password provided correct? * -- cgit v1.2.3