当前位置: 首页>>代码示例>>PHP>>正文


PHP CustomField::save方法代码示例

本文整理汇总了PHP中CustomField::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomField::save方法的具体用法?PHP CustomField::save怎么用?PHP CustomField::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CustomField的用法示例。


在下文中一共展示了CustomField::save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveCustomField

 /**
  * Save CustomField
  * @param CustomField $customField
  * @returns CustomField
  * @throws DaoException, DataDuplicationException
  */
 public function saveCustomField(CustomField $customField)
 {
     try {
         $q = Doctrine_Query::create()->from('CustomField c')->where('c.name = ?', $customField->name)->andWhere('c.id <> ?', $customField->id);
         $freeNum = null;
         if (empty($customField->id)) {
             $q = Doctrine_Query::create()->select('c.field_num')->from('CustomField c')->orderBy('id');
             $fieldNumbers = $q->execute(array(), Doctrine::HYDRATE_SCALAR);
             $count = count($fieldNumbers);
             $i = 1;
             foreach ($fieldNumbers as $num) {
                 if ($num['c_id'] > $i) {
                     $freeNum = $i;
                     break;
                 }
                 $i++;
                 if ($i > 10) {
                     break;
                 }
             }
             if (empty($freeNum) && $i <= 10) {
                 $freeNum = $i;
             }
             $customField->id = $freeNum;
         }
         if (!empty($customField->id)) {
             $customField->save();
         }
         return $customField;
         // @codeCoverageIgnoreStart
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
     // @codeCoverageIgnoreEnd
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:41,代码来源:CustomFieldConfigurationDao.php

示例2: postCreate

 public function postCreate()
 {
     $campoextra = new CustomField();
     $campoextra->name = Input::get('name');
     $campoextra->type = Input::get('type');
     $validation = $campoextra->validate();
     if ($validation->fails()) {
         return Redirect::to('backend/camposextra/create')->withInput()->withErrors($validation->getMessageBag());
     }
     $campoextra->save();
     return Redirect::to('backend/camposextra/view/' . $campoextra->id)->with('message', 'El campo extra ha sido creado.');
 }
开发者ID:e-gob,项目名称:api-instituciones-v2,代码行数:12,代码来源:CamposExtraController.php

示例3: testFormat

 public function testFormat()
 {
     $f = new CustomField();
     $f->name = "test 1";
     $f->format = "IP";
     $f->element = "text";
     $f->save();
     //print_r($f->attributes);
     //print($f);
     //print("Uhm, format is: ".$f->attributes['format']);
     //print("Lemme try this: ".$f->getAttribute('format'));
     //print("Moar: ".print_r($f->getAttributes(),true));
     $this->assertEquals($f->getAttributes()['format'], CustomField::$PredefinedFormats['IP']);
     //this seems undocumented...
     $this->assertEquals($f->format, "IP");
 }
开发者ID:rrsc,项目名称:snipe-it,代码行数:16,代码来源:CustomFieldTest.php

示例4: testUpdateValueOnCustomFieldRows

 /**
  * @depends testSetAttributesWithPostForCustomField
  */
 public function testUpdateValueOnCustomFieldRows()
 {
     $values = array('A', 'B', 'C');
     $customFieldData = CustomFieldData::getByName('updateItems');
     $customFieldData->serializedData = serialize($values);
     $this->assertTrue($customFieldData->save());
     $id = $customFieldData->id;
     $customField = new CustomField();
     $customField->value = 'A';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'B';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'C';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'C';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $quote = DatabaseCompatibilityUtil::getQuote();
     $customFieldTableName = CustomField::getTableName();
     $baseCustomFieldTableName = BaseCustomField::getTableName();
     $valueAttributeColumnName = 'value';
     $dataAttributeColumnName = RedBeanModel::getForeignKeyName('CustomField', 'data');
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id}";
     $ids = ZurmoRedBean::getCol($sql);
     $beans = ZurmoRedBean::batch($customFieldTableName, $ids);
     $customFields = RedBeanModel::makeModels($beans, 'CustomField');
     $this->assertEquals(4, count($customFields));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'B'";
     $this->assertEquals(1, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'C'";
     $this->assertEquals(2, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'E'";
     $this->assertEquals(0, count(ZurmoRedBean::getCol($sql)));
     CustomField::updateValueByDataIdAndOldValueAndNewValue($id, 'C', 'E');
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'B'";
     $this->assertEquals(1, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'C'";
     $this->assertEquals(0, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'E'";
     $this->assertEquals(2, count(ZurmoRedBean::getCol($sql)));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:84,代码来源:CustomFieldTest.php

示例5: testSavingCustomFieldDataLabels

 /**
  * @depends testAttributeLabelsMergeCorrectlyWithExistingData
  */
 public function testSavingCustomFieldDataLabels()
 {
     $a = new A();
     $this->assertTrue($a->isAttribute('fruitCstm'));
     unset($a);
     $appleCustomField = new CustomField();
     $appleCustomField->value = 'apple';
     $appleCustomField->data = CustomFieldData::getByName('Fruit');
     $this->assertTrue($appleCustomField->save());
     $attributeLabels = array('en' => 'fruit');
     ModelMetadataUtil::addOrUpdateCustomFieldRelation('A', 'fruit', $attributeLabels, $appleCustomField, true, false, 'DropDown', 'Fruit', array('apple', 'grape', 'orange'), array('fr' => array('appleFr', 'grapeFr', 'orangeFr'), 'de' => array('', 'grape', '')), 'CustomField', false);
     $a = new A();
     $a->a = 1;
     $this->assertTrue($a->isAttribute('fruitCstm'));
     $this->assertTrue($a->validate());
     $this->assertEquals('apple', $a->fruitCstm->value);
     $compareData = array('fr' => array('appleFr', 'grapeFr', 'orangeFr'), 'de' => array('', 'grape', ''));
     $this->assertEquals($compareData, unserialize($a->fruitCstm->data->serializedLabels));
     unset($a);
     ModelMetadataUtil::removeAttribute('A', 'fruitCstm');
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:24,代码来源:ModelMetadataUtilTest.php

示例6: save

 public function save($runValidation = true, array $attributeNames = null)
 {
     AuditUtil::throwNotSupportedExceptionIfNotCalledFromAnItem();
     return parent::save($runValidation, $attributeNames);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:5,代码来源:OwnedCustomField.php


注:本文中的CustomField::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。