On 16 dic, 11:44, Sebastian Göttschkes <sebastian.goettsch...@mpx-
e.de> wrote:
> Additionally, if I add a valid birthday, it is saved correctly. When
> editing the employee, I would like to get the birthday viewed in the
> format dd.mm.yyyy. How can I tell cake to view the birthday like this?

Ok, here's what I've done:

in the Obras edit / add view:

echo $html->div('input select',
    $form->label('fecha_creacion', 'Fecha de Creación')
    .
    $form->day('fecha_creacion', null, array(), '---')
    . ' - ' .
    $form->month('fecha_creacion', null, array(), '---')
    . ' - ' .
    $form->year('fecha_creacion', 1600, date('Y'), null, array(),
false)
);

This shows the div, a label and three select fields for day, month,
year, separated by ' - ', with the year between 1600 and the current
year, and day and month optional (these are the dates in which works
of art were made, and sometimes the date is not exact).

On the Obras controller, before saving:

$tmp = $this->data['Obra']['fecha_creacion'];
$this->data['Obra']['fecha_creacion'] = $tmp['year']; // year is
mandatory
if ($tmp['month']) {
    $this->data['Obra']['fecha_creacion'] .= '-' . $tmp['month'];
    if ($tmp['day']) {  // only if they selected a month
        $this->data['Obra']['fecha_creacion'] .= '-' . $tmp['day'];
    }
}

HTH
--
Saludos
Adriano
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to