diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-16 07:51:42 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-16 07:51:42 +0000 |
commit | 4610fc8e7f32f1a582b5f6c9c25714151b9a2967 (patch) | |
tree | bcfecbae267d03b231eb29b7a4f829fa96af1190 /modules/user/helpers | |
parent | ce7fbf979d249e5e1effb7040d3e51a2c35015e3 (diff) |
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.
Diffstat (limited to 'modules/user/helpers')
-rw-r--r-- | modules/user/helpers/user.php | 19 |
1 files changed, 17 insertions, 2 deletions
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,14 +19,29 @@ */ /** - * This helper provides a common around the user management functions. - * + * This helper provides a common around the user management functions. + * * @author Tim Almdal <public@timalmdal.com> * */ 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? * * @param user User Model |