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.

Revisions

  1. dmitrybelyakov created this gist Mar 5, 2014.
    61 changes: 61 additions & 0 deletions Form
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    /**
    * 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);
    }
    12 changes: 12 additions & 0 deletions data
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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
    )