Custom record edit view not loaded

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Firyo
    Senior Member
    • Jun 2022
    • 134

    Custom record edit view not loaded

    Hi there,

    I recently did a custom edit view for one of my custom entities.
    As I've read, the edit view is used for the creation of an entity and when you click the "Edit" button inside the detail view.
    Click image for larger version

Name:	image.png
Views:	293
Size:	26.8 KB
ID:	98440

    I added a
    Code:
    console.log("here");
    inside my
    Code:
    setup()
    function and it prints only when creating a new entity, not when I click on the "Edit" button inside the detail view.

    Am I missing something ?


    Documentation talking about that : https://docs.espocrm.com/development/custom-views/

    Regards,
    Firyo.​
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    I have just tried both record/detail and record/edit and it works for both below is an example for both for account entity, Please note for edit the console.log will be triggered once the Edit button is clicked:

    PHP Code:
    define('custom:views/account/record/detail',
        ['views/record/detail'], function (Dep) {
    
            return Dep.extend({
    
                setup: function(){
                    Dep.prototype.setup.call(this);
                    console.log("Editing in record/detail here");
                },
            });
    });
    PHP Code:
    define('custom:views/account/record/edit',
        ['views/record/edit'], function (Edit) {
    
            return Edit.extend({
    
                setup: function(){
                    Edit.prototype.setup.call(this);
                    console.log("Editing record/edit here");
                },
            });
    });
    Rabii
    Web Dev

    Comment

    • Firyo
      Senior Member
      • Jun 2022
      • 134

      #3
      Originally posted by rabii
      I have just tried both record/detail and record/edit and it works for both below is an example for both for account entity, Please note for edit the console.log will be triggered once the Edit button is clicked:

      PHP Code:
      define('custom:views/account/record/detail',
      ['views/record/detail'], function (Dep) {
      
      return Dep.extend({
      
      setup: function(){
      Dep.prototype.setup.call(this);
      console.log("Editing in record/detail here");
      },
      });
      });
      PHP Code:
      define('custom:views/account/record/edit',
      ['views/record/edit'], function (Edit) {
      
      return Edit.extend({
      
      setup: function(){
      Edit.prototype.setup.call(this);
      console.log("Editing record/edit here");
      },
      });
      });
      Hi rabii,

      First of all, thanks for your answer.

      I wanted to ask a question about the differences between 2 methods of editing an entity.

      Method 1 :
      Click image for larger version  Name:	image.png Views:	0 Size:	169.7 KB ID:	98478
      Click image for larger version  Name:	image.png Views:	0 Size:	113.4 KB ID:	98479

      Method 2 :
      Click image for larger version  Name:	image.png Views:	0 Size:	176.3 KB ID:	98480
      Click image for larger version  Name:	image.png Views:	0 Size:	157.9 KB ID:	98481
      Click image for larger version  Name:	image.png Views:	0 Size:	99.8 KB ID:	98482

      Because ​what I meant was the method 1.
      And my
      PHP Code:
      console.log("here"); 
      
      prints when creating a new entity and when I enter the full form in the method 2 (but it doesn't when I click the "Edit" button in the method 1).

      Regards,
      Firyo.
      Last edited by Firyo; 10-11-2023, 08:55 AM.

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #4
        Hey,

        The difference is each view will extend a view that has certain configuration and functions other than other views. The detail view is kind of parent as the edit view extend the detail and same for detailSmall and editSmall. i suggest that you go through the main views to understand how it works, tbh i am still learning too

        Rabii
        Web Dev

        Comment

        • yuri
          Member
          • Mar 2014
          • 8454

          #5
          1. Edit mode on the detail view. The view is the same but fields are switched to edit mode. Different buttons displayed. URL #EntityType/view/{id}.
          2. Edit view. The same view when you create a record. URL #EntityType/edit/{id}.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment


          • rabii
            rabii commented
            Editing a comment
            a question, i have been trying to use editModeDisabled on a custom record/detail but i am not sure i get it is purpose. as i understand on the record/detail custom view if i set thi editModeDisabled = true it should disable the button edit right ?

            /**
            * Disable edit mode. Can be overridden by an option parameter.
            *
            * @protected
            */
            editModeDisabled = false

            From the record/detail view class but i am not sure if that is its purpose. is this correct ?
        Working...