Why can't i remove edit button from detail view

i keep removing EDIT from buttons in detailviewdefs.php but nothing ever changes
anyone has an explanation

Can you please help understand if you remove the ‘EDIT’ button from the detail view, how the pencil edits would be handled. We can click on Pencil buttons and open the record in EDIT Mode, the record can be changed and saved using those pencil edit icons like ones are highlighted in the following image.

i found a way to remove them they are not mt problem now
my job now is to disable edit
but if there is a another way i am willing to know

and actually it doesn’t make sense to me easing the button in detailviewdefs.php and still finding it in detail view

Which module and on what condition you want to hide the ‘Edit’ button. I will try at my end and help you with the code changes.

leads module
when status is closed
thank you

Assuming the ‘pencil icons’ are not visible or disabled/Hidden. I have added some code changes to make Edit Button hidden when the lead is already converted.

Steps:

  1. Create a new file (DisableEdit.php) at the following path
    {ROOT}\extensions\defaultExt\config\modules\Leads\recordview\actions\DisableEdit.php

  2. Copy the below code in the file to change the definition of the ‘EDIT’ button.


<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\DependencyInjection\ContainerBuilder;

return static function (ContainerBuilder $container): void {

    $actions = $container->getParameter('module.recordview.actions') ?? [];
    $modules = $actions['modules'] ?? [];
    $leads = $modules['leads'] ?? [];
    $recordActions = $leads['actions'] ?? [];

	$edit_action=$actions['default']['actions']['edit'];
	$edit_action['display']='hide';
	$edit_action['displayLogic'] = [
		'edit-visible'=>[
		'key' => 'displayType',
		'modes' => ['detail'],
		'params' => [
			'fieldDependencies' => ['status'],
			'targetDisplayType' => 'default',
			'activeOnFields' => [
				'status' => [['operator'=>'not-equal','value'=>'Converted']],
			],
		 ],
		],
	];

	$recordActions['edit']=$edit_action;

	$leads['actions'] = $recordActions;
	$modules['leads'] = $leads;
	$actions['modules'] = $modules;
	$container->setParameter('module.recordview.actions', $actions);
};
  1. Delete cache/prod or run the following command from the ROOT directory path

    php bin/console cache:clear

  2. Clear browser cache and test the working of the code to see if the EDIT button is visibile when lead status is not ‘Converted.