示例#1
0
 /**
  * Detach field.
  * @throws SystemException 'ERR_DEV_NO_CONTROL_TO_DETACH'
  * @param FilterField $field filter field.
  */
 public function detachField(FilterField $field)
 {
     if (!isset($this->fields[$field->getIndex()])) {
         throw new SystemException('ERR_DEV_NO_CONTROL_TO_DETACH', SystemException::ERR_DEVELOPER);
     }
     unset($this->fields[$field->getIndex()]);
 }
示例#2
0
 /**
  * Create Grid filter
  * if there is filter description in config - load it
  * else  - create filter using DataDescription info
  */
 protected function createFilter()
 {
     if ($config = $this->getConfig()->getCurrentStateConfig()) {
         $this->filter_control = new Filter();
         $cInfo = $this->dbh->getColumnsInfo($this->getTableName());
         if ($this->getTranslationTableName()) {
             $cInfo = array_merge($cInfo, $this->dbh->getColumnsInfo($this->getTranslationTableName()));
         }
         if ($config->filter) {
             $this->filter_control->load($config->filter, $cInfo);
         } else {
             foreach ($this->getDataDescription() as $fName => $fAttributes) {
                 if (in_array($fAttributes->getType(), [FieldDescription::FIELD_TYPE_DATETIME, FieldDescription::FIELD_TYPE_DATE, FieldDescription::FIELD_TYPE_INT, FieldDescription::FIELD_TYPE_SELECT, FieldDescription::FIELD_TYPE_PHONE, FieldDescription::FIELD_TYPE_EMAIL, FieldDescription::FIELD_TYPE_STRING, FieldDescription::FIELD_TYPE_TEXT, FieldDescription::FIELD_TYPE_HTML_BLOCK, FieldDescription::FIELD_TYPE_BOOL]) && $fAttributes->getPropertyValue('index') != 'PRI' && !strpos($fName, '_num') && array_key_exists($fName, $cInfo)) {
                     $ff = new FilterField($fName, $fAttributes->getType());
                     $ff->setAttribute('tableName', $cInfo[$fName]['tableName']);
                     $ff->setAttribute('title', 'FIELD_' . $fName);
                     $this->filter_control->attachField($ff);
                 }
             }
         }
     }
 }