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


PHP MUtil_Model_ModelAbstract::getKeyCopyName方法代码示例

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


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

示例1: apply

 /**
  *
  * @param string $trackingField The field that stores the tracking value
  * @param string $trackedField   The field whose changing is tracked
  * @param string $oldValueField Optional, the field to store a copy of the original value in
  */
 public function apply($trackingField, $trackedField, $oldValueField = null)
 {
     if (null === $oldValueField) {
         // Defautl name
         $oldValueField = self::OLD_FIELD_PREFIX . $trackedField;
         // Check if a fields already existed
         if (method_exists($this->_model, 'getKeyCopyName')) {
             $copyName = $this->_model->getKeyCopyName($trackedField);
             if ($this->_model->has($copyName)) {
                 $oldValueField = $copyName;
             }
         }
     }
     if (!$this->_model->has($oldValueField)) {
         $this->_model->set($oldValueField, 'elementClass', 'Hidden', __CLASS__, $trackedField);
         $this->_model->setOnLoad($oldValueField, array($this, 'loadOldValue'));
     }
     if (!$this->_model->has($trackingField)) {
         // Only load the original value and ste the original result when it was not already in the model
         $this->_model->setAutoSave($trackingField);
         // $this->_model->setOnLoad($trackingField, $this->_unchangedValue);
     }
     $this->_model->set($trackingField, __CLASS__, array($trackedField, $oldValueField));
     $this->_model->setOnSave($trackingField, array($this, 'saveValue'));
     // Store the extra hidden fields needed
     $hiddenFields = $this->_model->getMeta(self::HIDDEN_FIELDS, array());
     $hiddenFields[] = $oldValueField;
     $this->_model->setMeta(self::HIDDEN_FIELDS, $hiddenFields);
     // Make sure the fields are in the result set
     $this->_model->get($trackedField);
     $this->_model->get($trackingField);
     $this->_model->get($oldValueField);
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:39,代码来源:ChangeTracker.php

示例2: addFormElements

 /**
  * Adds elements from the model to the bridge that creates the form.
  *
  * Overrule this function to add different elements to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @param array $data The data that will later be loaded into the form
  * @param optional boolean $new Form should be for a new element
  * @return void|array When an array of new values is return, these are used to update the $data array in the calling function
  */
 protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, array $data, $new = false)
 {
     $returnValues = array();
     if (APPLICATION_ENV !== 'production') {
         $bsn = new \MUtil_Validate_Dutch_Burgerservicenummer();
         $num = mt_rand(100000000, 999999999);
         while (!$bsn->isValid($num)) {
             $num++;
         }
         $model->set('grs_ssn', 'description', sprintf($this->_('Random Example BSN: %s'), $num));
     } else {
         $model->set('grs_ssn', 'description', $this->_('Enter a 9-digit SSN number.'));
     }
     if ($model->hashSsn === \Gems_Model_RespondentModel::SSN_HASH) {
         if (strlen($data['grs_ssn']) > 9) {
             // When longer the grs_ssn contains a hash, not a bsn number
             $returnValues['grs_ssn'] = '';
         }
     }
     $ucfirst = new \Zend_Filter_Callback('ucfirst');
     // \MUtil_Echo::track($data);
     $bridge->addTab('caption1')->h4($this->_('Identification'));
     //Add the hidden fields after the tab, so validation will work. They need to be in the
     //same tab where they are needed
     $bridge->addHidden('grs_id_user');
     $bridge->addHidden('gr2o_id_organization');
     $bridge->addHidden($model->getKeyCopyName('gr2o_patient_nr'));
     $bridge->addHidden($model->getKeyCopyName('gr2o_id_organization'));
     if (isset($data['gul_id_user'])) {
         $bridge->addHidden('gul_id_user');
     }
     $bridge->addText('grs_ssn', 'label', $this->_('SSN'), 'size', 10, 'maxlength', 12)->addValidator(new \MUtil_Validate_Dutch_Burgerservicenummer())->addValidator($model->createUniqueValidator('grs_ssn'))->addFilter('Digits');
     $bridge->addText('gr2o_patient_nr', 'label', $this->_('Patient number'), 'size', 15, 'minlength', 4)->addValidator($model->createUniqueValidator(array('gr2o_patient_nr', 'gr2o_id_organization'), array('gr2o_id_user' => 'grs_id_user', 'gr2o_id_organization')));
     $bridge->addText('grs_first_name')->addFilter($ucfirst);
     $bridge->addText('grs_surname_prefix', 'description', 'de, van der, \'t, etc...');
     $bridge->addText('grs_last_name', 'required', true)->addFilter($ucfirst);
     $bridge->addTab('caption2')->h4($this->_('Medical data'));
     $bridge->addRadio('grs_gender', 'separator', '', 'multiOptions', $this->util->getTranslated()->getGenders());
     $year = intval(date('Y'));
     // Als jQuery 1.4 gebruikt wordt: yearRange = c-130:c0
     $bridge->addDate('grs_birthday', 'jQueryParams', array('defaultDate' => '-30y', 'maxDate' => 0, 'yearRange' => $year - 130 . ':' . $year))->addValidator(new \MUtil_Validate_Date_DateBefore());
     //$bridge->addSelect(  'gr2o_id_physician');
     $bridge->addText('gr2o_treatment', 'size', 30, 'description', $this->_('DBC\'s, etc...'));
     $bridge->addTextarea('gr2o_comments', 'rows', 4, 'cols', 60);
     $bridge->addTab('caption3')->h4($this->_('Contact information'));
     // Setting e-mail to required is niet mogelijk, grijpt te diep in
     // misschien later proberen met ->addGroup('required', 'true'); ???
     $bridge->addText('grs_email', 'size', 30)->addValidator('SimpleEmail');
     $bridge->addCheckBox('calc_email', 'label', $this->_('Respondent has no e-mail'));
     $bridge->addRadio('gr2o_mailable');
     $bridge->addText('grs_address_1', 'size', 40, 'description', $this->_('With housenumber'))->addFilter($ucfirst);
     if ($model->has('grs_address_2')) {
         $bridge->addText('grs_address_2', 'size', 40);
     }
     $bridge->addText('grs_zipcode', 'size', 7, 'description', '0000 AA');
     $bridge->addFilter('grs_zipcode', new \Gems_Filter_DutchZipcode());
     $bridge->addText('grs_city')->addFilter($ucfirst);
     $bridge->addSelect('grs_iso_country', 'label', $this->_('Country'), 'multiOptions', $this->util->getLocalized()->getCountries());
     $bridge->addText('grs_phone_1', 'size', 15)->addValidator('Phone');
     $bridge->addTab('caption4')->h4($this->_('Settings'));
     $bridge->addSelect('grs_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages());
     $bridge->addRadio('gr2o_consent', 'separator', '', 'description', $this->_('Has the respondent signed the informed consent letter?'), 'required', true);
     return $returnValues;
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:76,代码来源:RespondentAction.php


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