本文整理汇总了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());
}
}
}
示例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));
}
示例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'));
}