?
avatar shoulders
shoulders
22 Nov 2020

Steps to reproduce the issue

If you edit any item that includes both following layouts (which most do) the id field is included twice:

  • (joomla.edit.global)
    $fields = $displayData->get('fields') ?: array(
    array('parent', 'parent_id'),
    array('published', 'state', 'enabled'),
    array('category', 'catid'),
    'featured',
    'sticky',
    'access',
    'id',
    'language',
    'tags',
    'note',
    'version_note',
    );
  • (joomla.edit.publishingdata)
    $fields = $displayData->get('fields') ?: array(
    'publish_up',
    'publish_down',
    array('created', 'created_time'),
    array('created_by', 'created_user_id'),
    'created_by_alias',
    array('modified', 'modified_time'),
    array('modified_by', 'modified_user_id'),
    'version',
    'hits',
    'id'
    );

The id field is also hidden by the global layout which causes it to be hidden in both the global and publishingdata renders.

$hiddenFields[] = 'id';

Expected result

  • Now I am not 100% sure what the intended result should be.
  • It looks like to me that the id was supposed to be hidden on the global layout but still be displayed on the publishingdata layout.
  • The id must be rendered at least once.
  • I would like to see the id shown as it used to be.

If you remove id from the $hiddenFields[] then you get the following (i.e. the id is now shown twice in the edit contact form):

  • Edit Contact/ First Tab
    image
  • Publishing Tab
    image

Actual result

The id field is rendered twice but both instances are hidden.

  • Edit Contact/ First Tab
    image
  • Publishing Tab
    image

System information (as much as possible)

Setting Value
 
PHP Built On Windows NT E6540 10.0 build 19041 (Windows 10) AMD64
Database Type mysql
Database Version 5.5.5-10.4.10-MariaDB
Database Collation utf8mb4_unicode_ci
Database Connection Collation utf8mb4_general_ci
PHP Version 7.3.12
Web Server Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.12
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.9.22 Stable [ Amani ] 6-October-2020 15:00 GMT
Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0

Additional comments

a good example file is:

I do not know if this is present in Joomla 4

avatar shoulders shoulders - open - 22 Nov 2020
avatar joomla-cms-bot joomla-cms-bot - change - 22 Nov 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 22 Nov 2020
avatar shoulders shoulders - change - 22 Nov 2020
Title
admin edit item forms have `id` rendered twice but is then disabled
admin edit item forms have `id` rendered twice but is then hidden
avatar shoulders shoulders - edited - 22 Nov 2020
avatar brianteeman
brianteeman - comment - 22 Nov 2020

Please see #22166

avatar brianteeman
brianteeman - comment - 27 Nov 2020

This should be closed as expected behaviour

avatar Quy Quy - change - 27 Nov 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-11-27 22:02:33
Closed_By Quy
avatar Quy Quy - close - 27 Nov 2020
avatar shoulders
shoulders - comment - 27 Nov 2020

cannot be expected behaviour. id field is always hidden so cannot be displayed in publishingdta fields.

if present in global why have it present in publishingdata?

easy to fix, after rendering the id filed in glibal removr it from hidden fileds.

avatar brianteeman
brianteeman - comment - 27 Nov 2020

@shoulders please read the link I posted

avatar shoulders
shoulders - comment - 27 Nov 2020

@brianteeman i did read the link. it says the id is needed for for something, my issue is the id field is rendered twice and for both instances is hidden.

  • if you need the id in the global layout and hidden, that is fine. this ensures the id is present for all records.
  • the id field in the publishingdata is hidden because the id field on global is hidden. i want to display the id field but i cannot because of the code hiding in global layout. this is should be easy to fix, one line of code and this should not have any affect on that issue.
  • currently i cannot visibly render id field at all because it is hidden. i could probably start messing with javascript but does not seem right way.

is it worth me having a play with some code so i can show you what i mean if i can get it working?

tar

avatar shoulders
shoulders - comment - 28 Nov 2020

The following code might be left in for legacy reasons, I am not sure. It seems to do nothing and always create an empty array.

  • in contact model --> "getHidden_fields" method does not exists
  • in CMSObject class ( --> "hidden_fields" property does not exist
    $hiddenFields = $displayData->get('hidden_fields') ?: array();

Here are my solutions for the hidden field

  • dont hide the ID field. this is useful information
  • (Optionally) remove the id field from the publishingdata layout, people might or might not use this if it was visible.

    or
  • only hide the ID field in the global layout (this should not affect any code in the other issue you mention)
    foreach ($fields as $field)
    {
    foreach ((array) $field as $f)
    {
    if ($form->getField($f))
    {
    if (in_array($f, $hiddenFields))
    {
    $form->setFieldAttribute($f, 'type', 'hidden');
    }
    $html[] = $form->renderField($f);
    break;
    }
    }
    }

    goes to
foreach ($fields as $field)
{
	foreach ((array) $field as $f)
	{
		if ($form->getField($f))
		{
			if (in_array($f, $hiddenFields))
			{
				$currentFieldType = $form->getFieldAttribute($f, 'type');
				$form->setFieldAttribute($f, 'type', 'hidden');
			}

			$html[] = $form->renderField($f);
            
			if (in_array($f, $hiddenFields))
			{
				$form->setFieldAttribute($f, 'type', $currentFieldType);
				unset($currentFieldType);
			}
            
			break;
		}
	}
}
avatar infograf768
infograf768 - comment - 28 Nov 2020

See #25096 for j4

Add a Comment

Login with GitHub to post a comment