? ? Pending

User tests: Successful: Unsuccessful:

avatar YatharthVyas
YatharthVyas
12 May 2021

Pull Request for Issue #33801

Summary of Changes

Refactored the foreach block. The loop iteration is executed if the field's value exists and its parent Field Group is to be displayed.

Testing Instructions

  1. Activate user profile
  2. Create a contact
  3. Set display user profile
  4. Create a custom field in users (Multiple fields under multiple field groups are recommended for thorough testing)
  5. Let the field empty in the user's profile
  6. Create a contact menu item
  7. Visit the contact created from Frontend

Before the PR, you will be able to see the field groups for all possible groups, including those left blank.
After the PR, Only those groups will be shown that have a field with a value.


Actual result BEFORE applying this Pull Request

image

Expected result AFTER applying this Pull Request

image

Documentation Changes Required

None

avatar YatharthVyas YatharthVyas - open - 12 May 2021
avatar YatharthVyas YatharthVyas - change - 12 May 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 May 2021
Category Front End com_contact
avatar YatharthVyas YatharthVyas - change - 12 May 2021
Labels Added: ?
avatar sandramay0905 sandramay0905 - test_item - 12 May 2021 - Tested successfully
avatar sandramay0905
sandramay0905 - comment - 12 May 2021

I have tested this item successfully on 8da070d

Without pull request

Screenshot_2021-05-12 Contact

With pull request

Screenshot_2021-05-12 Contact(1)

With pull request, no empty field

Screenshot_2021-05-12 Contact(2)


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33818.
avatar joomdonation
joomdonation - comment - 12 May 2021

I haven't tested but I think you are making more change than needed (and even the current code is having more lines of code than it should)

I think all you need to do is change the current block of code https://github.com/joomla/joomla-cms/blob/4.0-dev/components/com_contact/tmpl/contact/default_user_custom_fields.php#L29-L32 with something like:

<?php if ($field->value) : ?>
		<?php $userFieldGroups[$field->group_title][] = $field; ?>
<?php endif; ?>

No need for defining an extra array, no need for initialize $userFieldGroups[$field->group_title] with an empty array like in the current code.

Or even better, you can move the $field->value check to the if check at the top https://github.com/joomla/joomla-cms/blob/4.0-dev/components/com_contact/tmpl/contact/default_user_custom_fields.php#L26, and then remove these lines of code https://github.com/joomla/joomla-cms/blob/4.0-dev/components/com_contact/tmpl/contact/default_user_custom_fields.php#L29-L31 and everything will just work well.

Hope I don't miss anything.

avatar YatharthVyas YatharthVyas - change - 12 May 2021
The description was changed
avatar YatharthVyas YatharthVyas - edited - 12 May 2021
avatar YatharthVyas
YatharthVyas - comment - 12 May 2021

Thanks, @joomdonation for the amazing solution. It worked out perfectly!

@sandramay0905 Thank you for testing. If you have time, could you please re-test.

Edit: Please wait before testing, I will be adding one more commit to remove some extra code

Edit 2: Thank you for your patience, you may test the code now

avatar YatharthVyas YatharthVyas - change - 12 May 2021
The description was changed
avatar YatharthVyas YatharthVyas - edited - 12 May 2021
avatar joomdonation joomdonation - test_item - 13 May 2021 - Tested successfully
avatar joomdonation
joomdonation - comment - 13 May 2021

I have tested this item successfully on ec93131


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33818.

avatar ceford
ceford - comment - 13 May 2021

I created a Group, then went to create a Field and got a 500 error:

500 Unknown column 'a.only_use_in_subform' in 'field list'
JROOT/administrator/components/com_fields/src/View/Fields/HtmlView.php:90

This before applying the patch. I just merged the latest origin into my local copy. I don't know what has wrong but I can't test this PR.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33818.

avatar joomdonation
joomdonation - comment - 13 May 2021

@ceford Your Joomla is outdated. If it is possible, please download nightly build and re-install it. Or if you don't want to re-install, update to Joomla 4 nightly build, then run this SQL command to your database:

ALTER TABLE `#__fields` ADD COLUMN `only_use_in_subform` tinyint(1) NOT NULL DEFAULT 0;

Of course you need to replace #__fields with correct database table on your site (depends on the table prefix which you are using for your Joomla installation)

avatar sandramay0905 sandramay0905 - test_item - 13 May 2021 - Tested successfully
avatar sandramay0905
sandramay0905 - comment - 13 May 2021

I have tested this item successfully on ec93131


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33818.

avatar joomdonation joomdonation - change - 13 May 2021
Status Pending Ready to Commit
avatar joomdonation
joomdonation - comment - 13 May 2021

Thanks !


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33818.

avatar ceford
ceford - comment - 13 May 2021

It is not that my installation is out of date. I simply forgot that there is a Database Update option. Anyone, we have two tests so all good.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33818.

avatar richard67 richard67 - change - 13 May 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-05-13 13:12:06
Closed_By richard67
Labels Added: ?
avatar richard67 richard67 - close - 13 May 2021
avatar richard67 richard67 - merge - 13 May 2021
avatar richard67
richard67 - comment - 13 May 2021

Thanks!

avatar YatharthVyas
YatharthVyas - comment - 13 May 2021

Thanks all

Add a Comment

Login with GitHub to post a comment