I am currentry trying to build a form a Doctrine entity.  I have added the
required annotations to my entity.  I have also added the required code to
the controllers and view page but the form elements are not created.

When I have a look at the source code on the browser, the form tags are
created but not the elements themselves.

this is my entity:

<?php

namespace Blog\Entity;

use Doctrine\ORM\Mapping as ORM;
use Zend\Form\Annotation;

/**
 * BlogCategories
 *
 * @ORM\Table(name="blog_categories")
 *
@ORM\Entity(repositoryClass="\Blog\Entity\Repository\BlogCategoriesRepository")
 * @Annotation\Name("blog_categories")
 * @Annotation\Attributes({ "class": "form-horizontal" })
 * @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
 */
class BlogCategories
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @Annotation\Attributes({"type":"hidden"})
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=100, nullable=true)
     * @Annotation\Attributes({"type":"text"})
     * @Annotation\Options({"label":"Code:"})
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(name="description", type="string", length=255,
nullable=true)
     * @Annotation\Attributes({"type":"text"})
     * @Annotation\Options({"label":"Code:"})
     */
    private $description;

    /**
     * @var integer
     *
     * @ORM\Column(name="active", type="integer", nullable=true)
     * @Annotation\Attributes({"type":"text"})
     * @Annotation\Options({"label":"Code:"})
     */
    private $active;

    /**
     * @var string
     *
     * @ORM\Column(name="image", type="string", length=100, nullable=true)
     * @Annotation\Attributes({"type":"text"})
     * @Annotation\Options({"label":"Code:"})
     */
    private $image;

    /**
     * @var string
     *
     * @ORM\Column(name="slug", type="string", length=255, nullable=true)
     * @Annotation\Attributes({"type":"text"})
     * @Annotation\Options({"label":"Code:"})
     */
    private $slug;
}


Controller action:

public function addAction()
    {
        try {
            //$form = new BlogForm();

            $builder = new AnnotationBuilder($this->em);
            $form = $builder->createForm(new BlogCategories());

            $form->add(
                array(
                'name' => 'submit',
                'attributes' => array(
                    'type'  => 'submit',
                    'value' => 'Save',
                    'class' => 'btn btn-primary',
                    'id' => 'submitbutton',
                ),
            ));

            $view = new ViewModel();
            $view->setVariable('form', $form);
            $view->setVariable('pageTitle', 'Add Blog Post');
            $view->setTemplate('blog/admin/manage-post.phtml');
            return $view;
        } catch (\Exception $ex) {
            echo "<pre>";
            \Doctrine\Common\Util\Debug::dump($ex->getMessage());
            echo "</pre>";
        }


    }

View:
<div class="row-fluid">
            <?php
            $form = $this->form;
            $form->prepare();
            ?>
            <?php echo $this->form()->openTag($form); ?>
            <div class="span12">
                <?php echo $this->formCollection($form); ?>
            </div>

            <?php //echo $this->formSubmit($form->get('submit')); ?>

            <?php echo $this->form()->closeTag(); ?>
        </div>

Any particular reason why the elements are not being displayed??

Many thanks..



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Form-not-being-displayed-when-using-Form-annotations-tp4660124.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to