Created
July 31, 2012 07:48
-
-
Save awartoft/3214635 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Jonas Eriksson <[email protected]> | |
* @author Antoine Hedgecock <[email protected]> | |
*/ | |
/** | |
* @namespace | |
*/ | |
namespace Article\Form\Fieldsets; | |
use Zend\Form\Fieldset, | |
Zend\InputFilter\InputFilterProviderInterface; | |
class ArticleFieldset extends Fieldset implements InputFilterProviderInterface | |
{ | |
public function __construct() | |
{ | |
parent::__construct('article'); | |
$this->setObject(new \Article\Entity\Article()) | |
->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods()); | |
$this->add( | |
array( | |
'name' => 'topic', | |
'options' => array( | |
'label' => 'Rubrik' | |
), | |
'attributes' => array( | |
'required' => 'required' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'introduction', | |
'options' => array( | |
'label' => 'Ingress', | |
), | |
'attributes' => array( | |
'style' => 'height:60px;overflow-y:scroll;', | |
'required' => 'required' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'fact', | |
'options' => array( | |
'label' => 'Fakta', | |
), | |
'attributes' => array( | |
'style' => 'height:60px;overflow-y:scroll;' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'twitter', | |
'options' => array( | |
'label' => 'Twitter', | |
), | |
'attributes' => array( | |
'style' => 'height:60px;overflow-y:scroll;' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'body', | |
'options' => array( | |
'label' => 'Brödtext', | |
), | |
'attributes' => array( | |
'class' => 'editor_textarea', | |
'style' => 'height:360px;', | |
'required' => 'required' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'published_at', | |
'options' => array( | |
'label' => 'Publiceringsdatum', | |
), | |
'attributes' => array( | |
'value' => date('Y-m-d H:i'), | |
'required' => 'required' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'author', | |
'type' => 'User\Form\Fieldsets\UserRelationFieldset', | |
'attributes' => array( | |
'required' => 'required' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'image_author', | |
'options' => array( | |
'label' => 'Fotograf', | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'image', | |
'options' => array( | |
'label' => 'Bild' | |
), | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'category', | |
'type' => 'Article\Form\Fieldsets\CategoryRelationFieldset', | |
'attributes' => array( | |
'style' => 'width: 329px;', | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'company', | |
'type' => 'Company\Form\Fieldsets\CompanyRelationFieldset', | |
'attributes' => array( | |
'style' => 'width: 329px;', | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'keywords', | |
'type' => 'Zend\Form\Element\Collection', | |
'options' => array( | |
'label' => 'Keywords', | |
'allow_add' => true, | |
'should_create_template' => true, | |
'target_element' => array( | |
'type' => 'Keyword\Form\Fieldsets\KeywordRelationFieldset' | |
) | |
), | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'municipalities', | |
'type' => 'Zend\Form\Element\Collection', | |
'options' => array( | |
'label' => 'Geografisk anknytning', | |
'should_create_template' => true, | |
'allow_add' => true, | |
'target_element' => array( | |
'type' => 'GeographicalArea\Form\Fieldsets\MunicipalityRelationFieldset' | |
) | |
), | |
) | |
); | |
} | |
/** | |
* @return array | |
*/ | |
public function getInputFilterSpecification() | |
{ | |
return array( | |
'topic' => array( | |
'required' => true, | |
), | |
'introduction' => array( | |
'required' => true, | |
), | |
'body' => array( | |
'required' => true, | |
), | |
'fact' => array( | |
'required' => true, | |
'allow_empty' => true | |
), | |
'image_author' => array( | |
'required' => true, | |
'allow_empty' => true | |
), | |
'published_at' => array( | |
'required' => true | |
), | |
'image' => array( | |
'required' => true, | |
'allow_empty' => true | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment