<?php

class Sinistro2_Form_ValorLitroCombustivel extends Agro_Form
{
    public function init()
    {
        $this->addElement('hidden', 'id', array('decorators' => $this->elementDecorator));

        $this->addElement('text', 'data_inicio', array(
          'decorators' => $this->elementDecorator,
          'label'      => 'Data de Início',
          'class'      => 'data',
          'required'   => true,
        ));

        $this->addElement('select', 'id_estado', array(
          'decorators'   => $this->elementDecorator,
          'label'        => 'Estado',
          'MultiOptions' => (new Sistema_Model_Estados())->getCombo(),
          'required'     => true
        ));

        $this->addElement('text', 'valor', array(
          'decorators' => $this->elementDecorator,
          'label'      => 'Valor',
          'class'      => 'combustivel',
          'required'   => true
        ));
    }

    public function populate(array $values)
    {
        if (array_key_exists("data_inicio", $values)) {
            $values['data_inicio'] = date('d/m/Y', strtotime($values['data_inicio']));
        }

        $values['valor'] = str_replace('.', ',', $values['valor']);

        parent::populate($values);
    }
}
