From the TODO:

* Form alter - get the weights into the roles table/form somehow?

Attached patch does this. It required a bit of fancy work to fix the issue that user.module isn't fully Forms API compliant (bypasses drupal_submit_form). As well as improving the interface, this patch has the added advantage of enabling cleanup of obsolete data when a role is deleted. It also provides other role-related modules a base to work from, i.e., they can require role_weights and then form_alter the role admin forms to add their own fields.

Also includes some minor code cleanup, e.g., use of {tablename}.

Comments

nedjo’s picture

StatusFileSize
new9.03 KB

Minor tweaks: add description to weight field, set save button lower weight than delete (it was floating to bottom in some cases).

pfaocle’s picture

Status: Needs review » Fixed

Tested and applied to cvs - thanks nedjo.

Will port all recent changes to 4.7 branch once I've taken a look at the other issues.

Anonymous’s picture

Status: Fixed » Closed (fixed)
nedjo’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new994 bytes

My previous patch passed the anonymous user and authenticated user names as type '#markup'. This leads to the error that the values are lost when the form is submitted--the role names become empty strings.

To solve this, we need to pass the role names as type '#value' instead. This patch does so and also retains the current label, e.g.,

anonymous user (locked)

by passing it as a form prefix.

I've tested this and it successfully resolves the bug.

pfaocle’s picture

Thanks nedjo! I'm working through the code now trying to get a decent 4.7 branch together before I look at 5.0. However, I'm having trouble with some of your code from this (previous) patch. I'm convinced it used to work, but now with the module enabled I can't add roles.

Removing the theme_role_weights_admin_new_role() theme function sorts it, and its probably around line 92:

$rows[] = array(form_render($form['name']), form_render($form['submit']));

Somehow the new role name isn't being passed and I'm getting a "You must specify a valid role name." error.

Can you shed any light on this?

pfaocle’s picture

Version: master » 4.7.x-1.x-dev
Assigned: nedjo » pfaocle
Status: Needs review » Fixed

Tentatively fixed - we needed to render the rest of the form? See modified patch attached - committed to 4.7 (HEAD updates to follow).

pfaocle’s picture

StatusFileSize
new1.57 KB

Tentatively fixed - we needed to render the rest of the form? See modified patch attached - committed to 4.7 (HEAD updates to follow).

nedjo’s picture

Thanks for fixing this. I believe the error comes from the changes to forms that require a token to be passed. Rendering the full form includes the token.

Anonymous’s picture

Status: Fixed » Closed (fixed)