Custom View depending field value

@peted
I recommend don’t change function ‘preDisplay’.

  1. Make function ‘getMetaDataFile’ in file …/view.detail.php
/* add */
    public function getMetaDataFile()
    {
        if ($this->bean->order_type == "Repair" || $this->bean->order_type == "Other" || $this->bean->order_type == "Stock") {
            $oldType = $this->type;
            $this->type = $oldType . 'ros';
        }
        $metadataFile = parent::getMetaDataFile();
        if ($this->bean->order_type == "Repair" || $this->bean->order_type == "Other" || $this->bean->order_type == "Stock") {
            $this->type = $oldType;
        }
        
        return $metadataFile;
    }
/* */
  1. Your metadata of detail view should have next format name of file: …/detailrosviewdefs.php . This file will work for “Repair” or “Other” or “Stock” the file ‘detailviewdefs.php’ will work for other.

This example for detailview, but you can do the same thing for editview.

2 Likes