Skip to content

Instantly share code, notes, and snippets.

@dmitrybelyakov
Created March 5, 2014 15:55
Show Gist options
  • Save dmitrybelyakov/9369957 to your computer and use it in GitHub Desktop.
Save dmitrybelyakov/9369957 to your computer and use it in GitHub Desktop.
Array
(
[id] => 11
[locale] => en_US
[status] => published
[path] => /11
[title] => Some example structure node
[slug] => with-alias
[layout] => layout/layout
[metaDescription] => Some example structure node
[metaKeywords] => Some example structure node
)
/**
* Construct
* Instantiates the form and configures input fields
*
* @return void
*/
public function __construct($name, array $options = array())
{
//init
parent::__construct($name, $options);
$this->add(new Element\Csrf('csrf'));
/*
* Meta elements
*/
$meta = new FieldSet('Meta');
//title
$title = new Element\Text('title');
$title->setLabel('Title');
$meta->add($title);
//slug
$slug = new Element\Text('slug');
$slug->setLabel('Slug');
$meta->add($slug);
//meta description
$metaDescription = new Element\Textarea('metaDescription');
$metaDescription->setLabel('Meta description');
$meta->add($metaDescription);
//meta keywords
$metaKeywords = new Element\Text('metaKeywords');
$metaKeywords->setLabel('Meta keywords');
$meta->add($metaKeywords);
//add meta
$meta->setAttributes(array('legend' => 'Custom metadata'));
$this->add($meta);
/*
* Templates
*/
$templates = new FieldSet('Templates');
$templateNames = array('' => 'Inherited');
foreach($this->templates as $template)
$templateNames[$template] = $template;
//layout
$layout = new Element\Select('layout');
$layout->setLabel('Layout template');
$layout->setValueOptions($templateNames);
$templates->add($layout);
//add templates
$templates->setAttributes(array('legend' => 'Templates'));
$this->add($templates);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment