Skip to content

Instantly share code, notes, and snippets.

@awartoft
Created July 7, 2012 18:10
Show Gist options
  • Save awartoft/3067501 to your computer and use it in GitHub Desktop.
Save awartoft/3067501 to your computer and use it in GitHub Desktop.
<?php
/**
* @author Antoine Hedgecock <[email protected]>
*/
/**
* @namespace
*/
namespace Company\Form;
use Zend\Form\Form,
Zend\InputFilter\InputFilter;
class OTM extends Form
{
public function __construct()
{
parent::__construct('company_otm');
$filter = new InputFilter();
$filter->add(array('required' => true), 'year')
->add(array('required' => true), 'month');
$this->setInputFilter($filter)
->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
$this->add(
array(
'name' => 'year',
'options' => array(
'label' => 'År'
),
'attributes' => array(
'options' => array_combine(
range(date('Y'), date('Y') + 1),
range(date('Y'), date('Y') + 1)
)
)
)
);
$this->add(
array(
'name' => 'month',
'options' => array(
'label' => 'Månad'
),
'attributes' => array(
'value' => date('m'),
'options' => array(
'Januari' => '01',
'Feburari' => '02',
'Mars' => '03',
'April' => '04',
'Maj' => '05',
'Juni' => '06',
'Juli' => '07',
'Augusti' => '08',
'September' => '09',
'Oktober' => '10',
'November' => '11',
'December' => '12'
)
),
)
);
$this->add(
array(
'type' => 'Company\Form\Fieldsets\Company',
)
);
$this->setValidationGroup('company[id]', 'year', 'month');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment