This builds on my other thread a little bit:
http://forums.modx.com/thread/97119/showing-user-extended-fields-alongside-normal-fields-in-manager, but I thought it was different enough to warrant a new thread.
After getting ClassExtender working, I decided to take customizing the user update page in the manger a step further. My hope is to organize the user fields to match the same order/groupings as the registration form. For testing purposes, I only worked with the Username field, but I hope to apply this same method to all the fields.
First, I created a script called user-forms.js to remove the username field:
jQuery(function($) {
$(window).bind("load", function() {
$('#modx-user-username').remove();
});
});
Inside the ExtraUsersFields plugin I have the jQuery library loading OnFormPreRender, and my user-forms script loading OnUserFormRender. Both using $modx->regClientStartupScript. This successfully removes the field.
Then, I re-add the username field inside the MyExtraUserFields chunk, using code similar to the sample fields. This will be where I do all the field ordering, add headers, etc.
<div class="x-form-item x-tab-item">
<label class="x-form-item-label" style="width:auto; font-weight:bold; float:none; font-size:12px">Username Testing</label>
<div class="x-form-item x-tab-item" id="x-form-el-modx-user-username">
<input type="text" name="username" value="[[+username]]" class="x-form-text x-form-field"
onClick="Ext.getCmp('modx-panel-user').markDirty();" />
</div>
</div>
One question here is do I still need
onClick="Ext.getCmp('modx-panel-user').markDirty();" on the fields?
To make my placeholder work, I setup a new plugin called rePopulateUserFields:
$uid = 9;
$user = $modx->getObject('modUser', $uid);
if ($user) {
$username = $user->get('username');
$profile = $user->getOne('Profile');
if ($profile) {
$modx->setPlaceholder('username', $username);
}
}
This is where my big problem is. I can't figure out how to get the ID of the user I'm editing. What I have above repopulates the username field correctly, but only for the user with an ID of 9.
To summarize my questions:
- Do I need to include onClick="Ext.getCmp('modx-panel-user').markDirty();" on my fields that aren't extended fields?
- How do I get the ID of the user I'm editing in the manager, as opposed to the ID of the user who is logged into the manager?
--Tentatively using $uid = htmlspecialchars($_GET['id']); as per my first reply below
- Finally, is this the best method to accomplish what I want? I feel like using jQuery might not be the best way to remove the fields, but it's all I could come up with.
Thanks for the help!
[ed. note: firebot6 last edited this post 8 years, 10 months ago.]