J3 Issue ?
avatar PhilETaylor
PhilETaylor
19 Oct 2018

Steps to reproduce the issue

Login to Joomla 3.9 frontend (and maybe earlier, not tested) as a registered user
Go to edit your profile

Expected result

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!

Actual result

Username (Optional) field label

screenshot 2018-10-19 at 01 45 28

avatar PhilETaylor PhilETaylor - open - 19 Oct 2018
avatar joomla-cms-bot joomla-cms-bot - change - 19 Oct 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Oct 2018
avatar ggppdk
ggppdk - comment - 20 Oct 2018

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

avatar ggppdk
ggppdk - comment - 20 Oct 2018

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

  • disabled or readonly
avatar brianteeman brianteeman - change - 30 Oct 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 30 Oct 2018
avatar PhilETaylor PhilETaylor - change - 10 Feb 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-02-10 21:32:20
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 10 Feb 2019

Add a Comment

Login with GitHub to post a comment