Announcement

Collapse
No announcement yet.

Front-end readOnly and custom Handler

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Front-end readOnly and custom Handler

    Hi Yuri,

    it's a normal behaviour for a "readOnly" field ?

    EspoCrm 8.0.5

    step :
    myField : readOnly

    custom handler :
    myField = moment();

    result :
    on front-end : myField = today
    after save
    myField => null


    But if
    myField : not readOnly

    result :
    on front-end : myField = today.
    after save
    myField = today

    So, if a field is readOnly.. only back-end can modify ?

    Best Regards
    Last edited by item; 11-23-2023, 10:17 PM.

  • #2
    Hi,

    I'm not Yuri but I think I could help.

    This behavior is here since the v7.2.0 (https://github.com/espocrm/espocrm/releases/tag/7.2.0)
    As you can see in the devblog :
    Click image for larger version

Name:	image.png
Views:	68
Size:	97.0 KB
ID:	100051

    I had the same issue as you and I found a """workarround"".
    Instead of setting the field as "readOnly" you give it a dynamic logic where it's always in readonly (Like in the example below).

    Inside the "clientDefs" file of your Entity
    PHP Code:
    "dynamicLogic": {
            
    "fields": {
                
    "fieldName": {
                    
    "readOnly": {
                        
    "conditionGroup": [
                            {
                                
    "type""notEquals",
                                
    "attribute""id",
                                
    "value""-1"
                            
    }
                        ]
                    }
                }
            }
        }
    ​ 
    Regards,
    Firyo.

    Comment


    • item
      item commented
      Editing a comment
      Hi Firyo,

      thanks for info and nice workaround.. 
      ​​​​​​​
      Regards

  • #3
    Setting read-only values server-side is a more proper way. Maybe even setting in both the front-end and the back-end.

    If you are using a setup-handler, you can just call this.view.setFieldReadOnly('yourField', true);

    Comment

    Working...
    X