所以我想在搜索中将选择字段中的日期显示为 dd/mm/yy 但我的数据库设置为 yy-mm-dd 所以我希望它被转换为数据库使用但仍然显示 dd/mm/yy为选择字段中的用户。
模型:
public function search($auditCriteria=null)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$cni = new ContractNoteItem();
$criteria->with =array('contractNoteItems'=>array('select'=>'{{contractNoteItems}}.*','joinType'=>'LEFT OUTER JOIN', ), );
if(isset($_GET['cni_client_account_no']) && $_GET['cni_client_account_no']!=0 && $_GET['cni_client_account_no']!=""){
// echo 2;
if(isset($_GET['cni_portfolio_id2']) && $_GET['cni_portfolio_id2']!=0 && $_GET['cni_portfolio_id2']!="")
{
// echo 3;
$criteria->join = 'RIGHT JOIN ial_contract_note_item ON ial_contract_note_item.cni_contract_note_id=t.id';
$criteria->condition = 'ial_contract_note_item.cni_contract_note_id=t.id';
$criteria->compare('cni_contract_note_id',$this->id);
$criteria->compare('ial_contract_note_item.cni_portfolio_id',$_GET['cni_portfolio_id2']);
}else{
// echo 4;
$criteria->join = 'RIGHT JOIN ial_contract_note_item ON ial_contract_note_item.cni_contract_note_id=t.id';
$criteria->condition = 'ial_contract_note_item.cni_contract_note_id=t.id';
$criteria->compare('cni_contract_note_id',$this->id);
$criteria->compare('ial_contract_note_item.cni_client_account_no',$_GET['cni_client_account_no']);
}
// echo 5;
}
// echo 6,
$criteria->compare('id',$this->id,true);
$criteria->compare('cn_fund_house_id',$this->cn_fund_house_id,true);
$criteria->compare('cn_investment_date',$this->cn_investment_date,true);
$criteria->compare('cn_settlement_date',$this->cn_settlement_date,true);
$criteria->compare('transaction_id',$this->transaction_id,true);
$criteria->compare('sub_transaction_id',$this->sub_transaction_id,true);
$criteria->compare('counter_party_trans_ref',$this->counter_party_trans_ref,true);
$criteria->compare('t.modified_by',$this->modified_by,true);
// $criteria->compare('ial_contract_note_item.cni_portfolio_id',$this->cni_portfolio_id,true);
if($auditCriteria != null && $auditCriteria)
{
//$criteria->compare('actual',1);
$criteria->compare('t.pending',1);
}
if(!$auditCriteria)
{
$criteria->compare('t.actual',1);
$criteria->compare('t.pending',0);
}
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
那么我应该如何进行呢?我用 altField 尝试了 altFormat,但它完全覆盖了日期格式,并且 db 无法识别实际的 dateFormat。我知道它必须与 before 和 after 函数有关,但似乎它们没有被加载