Skip to content

Instantly share code, notes, and snippets.

@awartoft
Created July 9, 2012 12:34
Show Gist options
  • Save awartoft/3076220 to your computer and use it in GitHub Desktop.
Save awartoft/3076220 to your computer and use it in GitHub Desktop.
<?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',
'options' => array(
'label' => 'Skribent'
),
'attributes' => array(
'value' => 1,
'required' => 'required'
)
)
);
$this->add(
array(
'name' => 'photographer',
'options' => array(
'label' => 'Fotograf',
)
)
);
$this->add(
array(
'name' => 'image',
'options' => array(
'label' => 'Bild'
),
)
);
$this->add(
array(
'name' => 'category_id',
'options' => array(
'label' => 'Kategori',
),
'attributes' => array(
'style' => 'width: 329px;',
)
)
);
$this->add(
array(
'name' => 'company_id',
'options' => array(
'label' => 'Företag (krävs ej)',
),
'attributes' => array(
'style' => 'width: 329px;',
)
)
);
$this->add(
array(
'name' => 'keywords',
'type' => 'Zend\Form\Element\Collection',
'options' => array(
'label' => 'Keywords',
'count' => 1,
'allow_add' => true,
'should_create_template' => true,
'target_element' => array(
'type' => 'Article\Form\Fieldsets\KeywordRelationFieldset'
)
),
)
);
$this->add(
array(
'name' => 'geographical_areas',
'type' => 'Zend\Form\Element\Collection',
)
);
}
/**
* @return array
*/
public function getInputFilterSpecification()
{
return array(
'topic' => array(
'required' => true,
),
'introduction' => array(
'required' => true,
),
'category_id' => array(
'required' => true,
),
'body' => array(
'required' => true,
),
'fact' => array(
),
'keywords' => array(
'required' => true
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment