當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Fields::setAttributes方法代碼示例

本文整理匯總了PHP中Fields::setAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Fields::setAttributes方法的具體用法?PHP Fields::setAttributes怎麽用?PHP Fields::setAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Fields的用法示例。


在下文中一共展示了Fields::setAttributes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: tryAddCol

 private static function tryAddCol($model, $col, $type)
 {
     if (!Fields::model()->findByAttributes(array('fieldName' => $col, 'modelName' => get_class($model)))) {
         $field = new Fields();
         $field->setAttributes(array('modelName' => get_class($model), 'fieldName' => $col, 'attributeLabel' => $col, 'modified' => '1', 'custom' => 1, 'type' => $type, 'required' => '0', 'uniqueConstraint' => '0', 'safe' => '1', 'readOnly' => '0', 'linkType' => NULL, 'searchable' => '0', 'relevance' => 'Low', 'isVirtual' => '0', 'defaultValue' => NULL, 'keyType' => '', 'data' => NULL), false);
         if (!$field->save()) {
             AuxLib::debugLogR('$col = ');
             AuxLib::debugLogR($col);
             AuxLib::debugLogR($field->getErrors());
         }
     }
 }
開發者ID:keyeMyria,項目名稱:CRM,代碼行數:12,代碼來源:FieldFormatterTest.php

示例2: actionManageFields

 /**
  * General field management.
  *
  * This action serves as the landing page for all of the custom field related
  * actions within the software.
  */
 public function actionManageFields()
 {
     // New model for the form:
     $model = new Fields();
     // Set up grid view:
     $searchModel = new Fields('search');
     $criteria = new CDbCriteria();
     $criteria->addCondition('modified=1');
     $searchModel->setAttributes(isset($_GET['Fields']) ? $_GET['Fields'] : array(), false);
     foreach ($searchModel->attributes as $name => $value) {
         $criteria->compare($name, $value);
     }
     $pageSize = Profile::getResultsPerPage();
     $dataProvider = new SmartActiveDataProvider('Fields', array('criteria' => $criteria, 'pagination' => array('pageSize' => Profile::getResultsPerPage())));
     // Set up fields list
     $fields = Fields::model()->findAllByAttributes(array('custom' => '1'));
     $arr = array();
     foreach ($fields as $field) {
         $arr[$field->id] = $field->attributeLabel;
     }
     $this->render('manageFields', array('dataProvider' => $dataProvider, 'model' => $model, 'searchModel' => $searchModel, 'fields' => $arr));
 }
開發者ID:xl602,項目名稱:X2CRM,代碼行數:28,代碼來源:AdminController.php

示例3: testCheckConversionCompatibility

 public function testCheckConversionCompatibility()
 {
     $field = Fields::model()->findByAttributes(array('modelName' => 'X2Leads', 'fieldName' => 'description'));
     $field->type = 'boolean';
     $this->assertSaves($field);
     Yii::app()->cache->flush();
     X2Leads::model()->resetFieldsPropertyCache();
     // ensure that conversion fails due to field type mismatch
     $lead = $this->x2Leads('1');
     $leadAttrs = $lead->getAttributes();
     $this->assertFalse($lead->checkConversionCompatibility('Contacts'));
     $this->assertFalse($lead->checkConversionCompatibility('Opportunity'));
     self::restoreFields();
     $this->assertTrue($lead->checkConversionCompatibility('Contacts'));
     $this->assertTrue($lead->checkConversionCompatibility('Opportunity'));
     // ensure that conversion fails due presence of extra field
     $extraField = new Fields();
     $extraField->setAttributes(array('modelName' => 'X2Leads', 'fieldName' => 'extraField', 'type' => 'boolean', 'attributeLabel' => 'Extra Field'));
     $this->assertSaves($extraField);
     Yii::app()->db->schema->refresh();
     $lead->refreshMetaData();
     Yii::app()->cache->flush();
     X2Leads::model()->resetFieldsPropertyCache();
     $lead->c_extraField = true;
     $this->assertFalse($lead->checkConversionCompatibility('Contacts'));
     $this->assertFalse($lead->checkConversionCompatibility('Opportunity'));
     self::restoreFields();
     $lead->refresh();
     $this->assertTrue($lead->checkConversionCompatibility('Contacts'));
     $this->assertTrue($lead->checkConversionCompatibility('Opportunity'));
 }
開發者ID:shuvro35,項目名稱:X2CRM,代碼行數:31,代碼來源:X2ModelConversionBehaviorTest.php


注:本文中的Fields::setAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。