Candidato -> arreglo en la fecha de nacimiento

git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_IntranetNueva/trunk@42 77cfc57b-8ef4-1849-9df6-4a38aa5da120
This commit is contained in:
David Arranz 2012-04-18 14:54:46 +00:00
parent ed206e620e
commit 2fbaff8849
3 changed files with 40 additions and 8 deletions

View File

@ -1,12 +1,6 @@
jQuery.noConflict();
jQuery(document).ready(function(){
/**
* Date picker
**/
jQuery( "#datepicker" ).datepicker();
/**
* Growl Notification
**/

View File

@ -172,7 +172,7 @@ class Candidato extends CActiveRecord
array('fecha_nacimiento, observaciones', 'safe'),
//array('fecha_nacimiento', 'date', 'allowEmpty'=>'true'),
array('fecha_nacimiento', 'date', 'format'=>'dd/MM/yyyy'),
array('estado', 'unsafe'),
@ -297,4 +297,25 @@ class Candidato extends CActiveRecord
return parent::beforeValidate();
}
protected function beforeSave()
{
//PHP dates are displayed as dd/mm/yyyy
//MYSQL dates are stored as yyyy-mm-dd
$unafecha = DateTime::createFromFormat('d/m/Y', $this->fecha_nacimiento);
$this->fecha_nacimiento = $unafecha->format('Y-m-d');
parent::beforeSave();
return true;
}
protected function afterFind() {
//PHP dates are displayed as dd/mm/yyyy
//MYSQL dates are stored as yyyy-mm-dd
$unafecha = DateTime::createFromFormat('Y-m-d', $this->fecha_nacimiento);
$this->fecha_nacimiento = $unafecha->format('d/m/Y');
parent::afterFind();
return true;
}
}

View File

@ -94,7 +94,24 @@ Yii::app()->clientScript->registerScript('wysiwyg', $script, CClientScript::POS_
<div class="padding1020">
<?php echo $form->labelEx($model,'fecha_nacimiento'); ?>
<div class="marginleft150">
<?php echo $form->textField($model,'fecha_nacimiento',array('class'=>'sf','id'=>'datepicker')); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'fecha_nacimiento',
'name'=>'fecha_nacimiento',
'language'=>'es',
'options'=>array(
'selectOtherMonths'=>true,
'showButtonPanel'=>true,
'showOtherMonths'=>true,
'changeMonth' => true,
'changeYear' => true,
),
'htmlOptions' => array(
'class' => 'sf',
)
));
?>
<?php echo $form->error($model,'fecha_nacimiento', array('class'=>'errortext')); ?>
</div>
</div>