Esempio n. 1
0
 /**
  * Determines the value for the element in the form view
  *
  * @param   array $data          form data
  * @param   int   $repeatCounter when repeating joined groups we need to know what part of the array to access
  * @param   array $opts          options
  *
  * @return  string    value
  */
 public function getValue($data, $repeatCounter = 0, $opts = array())
 {
     if ($this->getListModel()->importingCSV) {
         return parent::getValue($data, $repeatCounter, $opts);
     }
     $input = $this->app->input;
     // Kludge for 2 scenarios
     if (array_key_exists('rowid', $data)) {
         // When validating the data on form submission
         $key = 'rowid';
     } else {
         // When rendering the element to the form
         $key = '__pk_val';
     }
     /*
      * empty(data) when you are saving a new record and this element is in a joined group
      * $$$ hugh - added !array_key_exists(), as ... well, rowid doesn't always exist in the query string
      */
     if (empty($data) || !array_key_exists($key, $data)) {
         // $$$ rob - added check on task to ensure that we are searching and not submitting a form
         // as otherwise not empty validation failed on user element
         if (!in_array($input->get('task'), array('processForm', 'view', '', 'form.process', 'process'))) {
             return '';
         }
         return $this->getDefaultOnACL($data, $opts);
     }
     return parent::getValue($data, $repeatCounter, $opts);
 }