Wednesday 21 May 2014

[vTiger 6] Updated: How to disable editing on details view

vTiger 6 provides the ability to quick edit on details view for each module. This is an advantage but if you have a picklist dependency, it not will be controlated to AJAX on details view. It could induce a data inconsistency.

To solve this problem, edit on your module the file: vtigerinstallation_path\modules\module_name\views\Detail.php comment all lines inside the function public function getHeaderScripts(Vtiger_Request $request) { }
but not comment the function.

Example: Disable editing on service module.



public function getHeaderScripts(Vtiger_Request $request) {
    // I will to comment from here
    /*
    parent::getHeaderScripts($request);
    $headerScriptInstances = parent::getHeaderScripts($request);
    $moduleName = $request->getModule();
    $modulePopUpFile = 'modules.'.$moduleName.'.resources.Edit';
    unset($headerScriptInstances[$modulePopUpFile]);

    $jsFileNames = array(
'modules.Products.resources.Edit',
    );
    $jsFileNames[] = $modulePopUpFile;

    $jsScriptInstances = $this->checkAndConvertJsScripts($jsFileNames);
    $headerScriptInstances = array_merge($headerScriptInstances, $jsScriptInstances);
    return $headerScriptInstances;
    */ 
    //to here
    }


Now you can't edit the fields from details view.

Best regards.



Update:

Another way by Anonymous

On the showModuleDetailView function. I erased few lines, just to show that I comment the

"IS_AJAX_ENABLED" option in the array that returns the value of the field edit option. This way you didn't disable anything else that need the scripts and you disable the AJAX editing.

File: /modules/Vtiger/views/Detail.php:

function showModuleDetailView(Vtiger_Request $request)
{
  /*$viewer->assign('IS_AJAX_ENABLED', $this->isAjaxEnabled($recordModel));*/
}

function showModuleSummaryView($request)
{
  /*$viewer->assign('IS_AJAX_ENABLED', $this->isAjaxEnabled($recordModel));*/
}

11 comments:

  1. Hello. You just saved my life. Workflows not running when quick-editing were a pain in the a...
    For potentials and accounts, you have to do this in /modules/vtiger/views/detail.php.

    Best regards and thanks again.

    ReplyDelete
  2. Excellent, thank you very much. You save me a lot of code research, I was looking into this for a couple of hours in the code.

    ReplyDelete
  3. I'll like to add something for this need I just found. If you disable the scripts, then there is a few things that stop working, like clicking on the other related list to take its views.

    Maybe it will be easier to do this, on the showModuleDetailView function. I erased few lines, just to show that I comment the "IS_AJAX_ENABLED" option in the array that returns the value of the field edit option. This way you didn't disable anything else that need the scripts and you disable the AJAX editing.

    File: /modules/Vtiger/views/Detail.php:

    function showModuleDetailView(Vtiger_Request $request) {

    // $viewer->assign('IS_AJAX_ENABLED', $this->isAjaxEnabled($recordModel));

    }

    ReplyDelete
    Replies
    1. Thank you. I have updated the post with your solution.

      Delete
  4. Hi there, I was trying to add Form Save with Ajax for one of the custom modules, i followed Calendar Quick Create but its not working. Can you pls suggest anything for this?
    Thanku

    ReplyDelete
  5. Hey,

    Thank's for this, it's perfect for my module :)

    Best

    ReplyDelete
  6. Most of the time I don’t make comments on but I'd like to say that this article really forced me to do so. Really nice post!

    online assignment help
    affordable assignments

    ReplyDelete
  7. yet another simpler way: just override the constructor of Vtiger_Detail_View and set $this->isAjaxEnabled to false.

    public function __construct()
    {
    parent::__construct();
    $this->isAjaxEnabled = false;
    }

    ReplyDelete