hexagone Reply #1, 5 months, 4 weeks ago
I've created the following plugin to add an extended user field in the manage user form. Everything works fine and the data is properly saved. But the Save button stays greyed out even when I edit this new field, I have to edit one of the standard fields to have it activated.
Is there a class or javascript fonction I forgot to add ?
Is there a class or javascript fonction I forgot to add ?
<?php
/**
* Register a form field to forms
*/
switch ($modx->event->name) {
case 'OnUserFormPrerender':
/* if you want to add custom scripts, css, etc, register them here */
break;
case 'OnUserFormRender':
$v = '';
if (isset($scriptProperties['user'])) {
/* on the update screen, so set the value */
$user =& $scriptProperties['user'];
$profile = $user->getOne('Profile');
$extendedFields = $profile->get('extended');
$v = $extendedFields['categorie'];
} else {
/* on the create screen, so set the default */
$v = '';
}
/* now do the HTML */
$fields = '
<div class="x-form-item x-tab-item">
<label class="x-form-item-label" style="width:150px;">Categorie</label>
<div class="x-form-element">
<input name="categorie" type="input" class="x-form-text x-form-field" id="modx-user-categorie" value="'.$v.'">
</div>
</div>
';
$modx->event->output($fields);
break;
case 'OnUserFormSave':
/* do processing logic here. */
$user =& $scriptProperties['user'];
$profile = $user->getOne('Profile');
$extendedFields = $profile->get('extended');
$extendedFields['categorie'] = $_POST['categorie'];
$profile->set('extended',$extendedFields);
$profile->save();
return $output;
break;
}
return;