user3322020
user3322020

Reputation: 21

Zend framework 2 bootstrap is not working in my form

Just now created one form in Zend framework 2. The form is looking like this...

Please open this link to see my ouput image [Bcz I don't have 10 reputation].

http://www.tiikoni.com/tis/view/?id=bac011a

Now what can I do? How can I bring this form in bootstrap look?

Create.phtml

    <?php

    echo '<h1>Create</h1>';
    $form = $this->form;
    $form->prepare();
    $form->setAttribute('action', $this->url('csnuser/default', array('controller' =>               'user', 'action' => 'create')));
    $form->setAttribute('method', 'post');
    echo $this->form()->openTag($form);
    echo $this->formCollection($form);
    echo $this->form()->closeTag();
    ?>

Upvotes: 1

Views: 712

Answers (1)

Purple Hexagon
Purple Hexagon

Reputation: 3568

The following module allows you to do this:

https://github.com/neilime/zf2-twb-bundle - This is for Bootstrap 3.x there are other modules available for lesser versions but assume you are using the latest.

You shouldn't need to alter your code much at all. Probably be something like:

    $this->form($form,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL);

Some good demos and docs here: http://neilime.github.io/zf2-twb-bundle/2.0/demo.html

Upvotes: 2

Related Questions