Login to Joomla 3.9 frontend (and maybe earlier, not tested) as a registered user
Go to edit your profile
My username shown, ok so its disabled field, but the expectation is that it should NOT be optional as stated, how can it be optional, I cannot remove my username, a Joomla user requires a username!
Username (Optional) field label
Labels |
Added:
?
|
a simple fix is to patch the form template file ...
<?php if (!$field->required && $field->type !== 'Spacer') : ?>
<span class="optional">
<?php echo JText::_('COM_USERS_OPTIONAL'); ?>
</span>
<?php endif; ?>
i mean maybe it makes sense not add optional / required markings when a field
Labels |
Added:
J3 Issue
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-02-10 21:32:20 |
Closed_By | ⇒ | PhilETaylor |
Ok,
the field is not disabled ... it is readonly
so if you allow it to be required ... then Joomla default profile form
-- will succeed to save properly
but
then any custom template overrides that are now skipping the username field
(skipping when !JComponentHelper::getParams('com_users')->get('change_login_name'))
-- will fail to save
(i do not know how common this is or even if they hide it instead of skipping it, in which case saving will succeed)
I do not remember if there was a bug report for the above in the past
but i think there was
Also making the field both disabled and required
will again make the form to fail to save always
so i am afraid the
$form->setFieldAttribute('username', 'required', 'false');
inside model's code is deliberate ?
Maybe we need to make a fix / improvement inside JForm validation
to avoid failure when a field is both disabled and required
Also if there is custom code that is using a model instance to save the profile, and is not providing username when
JComponentHelper::getParams('com_users')->get('change_login_name')
is OFF will fail