Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Use zend_form inside jquery tabcontainer

  1. #1
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default Use zend_form inside jquery tabcontainer

    Hello, buddies

    I want to build a form inside tabcontainer (jquery) which contain 5 tabs. Each tab contain some elements in the form. How could I do that with zend form class?

    Thanks

  2. #2
    jsuggs is offline Junior Member
    Join Date
    Aug 2009
    Posts
    24

    Default

    Most likely you'll have to do that in with a ViewScript.

    Check out this article as I think it gives the most comprehensive explanation of how Zend_Form works.

    Decorators with Zend_Form

  3. #3
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default

    Quote Originally Posted by jsuggs View Post
    Most likely you'll have to do that in with a ViewScript.

    Check out this article as I think it gives the most comprehensive explanation of how Zend_Form works.

    Decorators with Zend_Form
    I read the article, but I still don't get the idea.
    I build some form as follow:
    Code:
    class Default_Form_My_Form extends Zend_Form
    {
        public function init()
        {
            $this->setAction('/do/something')
                 ->setMethod('post')
                 ->setAttrib('id', 'my_form');
        }
        
        public function setTabs($obj)
        {
            $tabs = $obj->tabs;
            foreach($tabs as $elements)
            {
                foreach($elements as $element)
                {
                    $this->addElement($element);
                }
            }
        }
        
    }
    In the above code I put all my elements in the form object.
    I can't put each tab in tabPane like in the next code:
    Code:
    $view->tabPane("tabs", $paneContent, array('title' => $tab->name));
    while $paneContent is html code of the tab.
    after that I can echo the tabs:
    Code:
    $this->tabContainer("tabs", array());
    How can I put each tab in tabPane via the form object?

  4. #4
    jsuggs is offline Junior Member
    Join Date
    Aug 2009
    Posts
    24

    Default

    I'm not a Zend_Form guru, so I don't know how you are going to do this the proper way, but what I was suggesting was to create the HTML markup manually and use it as the ViewScript.

    Maybe post what you want your eventual HTML output to be and we can reverse engineer the Zend_Form way to do it.

  5. #5
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default

    Quote Originally Posted by jsuggs View Post
    I'm not a Zend_Form guru, so I don't know how you are going to do this the proper way, but what I was suggesting was to create the HTML markup manually and use it as the ViewScript.

    Maybe post what you want your eventual HTML output to be and we can reverse engineer the Zend_Form way to do it.
    I need to build a zend_form object and output it to tabcontainer and each tab have a few elements from the form.

  6. #6
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default Pop up

    I'm stuck on this project almost one month.

    If someone know where can I find some info or examples about how to do that, I would be grateful.

    Thanks for the help.
    Last edited by oc666; 10-10-2009 at 02:29 PM.

  7. #7
    Laura Dean is offline Member
    Join Date
    Jun 2009
    Posts
    80

    Default

    Hey there, I've done this and can maybe help you out a bit.

    First, here is a link to the reference on ZendX_JQuery_Form which you will want to extend instead of Zend_Form:

    Zend Framework: Documentation

    You have to download ZendX separately, but that is where the support for this feature is. Each of your tabs is going to be set up as a subform and you must have the (form and subform) decorators properly configured. My decorators look like this:

    Code:
    $this->setDecorators(array(
        'FormElements',
        array('HtmlTag', array('tag' => 'div', 'id'=>'tabContainer', 'class'=>'mainForm')),
        array('TabContainer', array('id'=>'tabContainer', 'style'=>'width: 530px;')),
        'Form'
    ));
    $subform = new ZendX_JQuery_Form();
    $subform->setDecorators(array(
        'FormElements',
        array('HtmlTag', array('tag' => 'div', 'class'=>'subForm')),
        array('TabPane', array('jQueryParams' => 
                              array('containerId' => 'mainForm', 
                                      'title' => "Page " . $subform_cnt))),
        'Form',
    ));
    And then of course add the jQuery calls to your view...

    Code:
    <script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="/js/jquery-ui-1.7.2.custom.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#tabContainer").tabs();
        });
    </script>
    If you have more questions I'll try to help.

  8. #8
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default

    Laura Dean, thanks for your reply.
    I don't understand why i need to put each tab in sub-form, if all the data from all tabs send to one target.
    I thought and tried to do that with display group and I didn't success to do that.

    Thanks.

  9. #9
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default Solved

    With some tweaks I successed to get it work with the next code:
    [PHP]
    $this->setDecorators(array(
    'FormElements',
    array('HtmlTag', array('tag' => 'div', 'id'=>'tabContainer', 'class'=>'mainForm')),
    array('TabContainer', array('id'=>'tabContainer')),
    'Form'
    ));


    foreach($tabs as $tab)
    {
    $elements = $tab->elements;
    $this->addElements($elements);
    $this->addDisplayGroup($tab->elements_names, $tab->name,
    array('disableLoadDefaultDecorators' => true));
    $display_group = $this->getDisplayGroup($tab->name);
    $display_group->setDecorators(array(
    'FormElements',
    array('HtmlTag', array('tag' => 'div')),
    array('TabPane', array('jQueryParams' =>
    array('containerId' => $this->id,
    'title' => "Page " . $tab->name))),
    'Form',
    ));
    }
    [/PHP]

    Laura Dean - Thanks for the tip.

  10. #10
    oc666 is offline Junior Member
    Join Date
    Feb 2009
    Location
    Israel
    Posts
    14

    Default

    with the above example i've got html bug with div which contain form variables (like method and action):
    [PHP]
    <div id="tabContainer" class="ui-tabs ui-widget ui-widget-content ui-corner-all"
    method="post" action="/catalog/save">
    [/PHP]
    I don't know if it's my syntax of the php code or zend framework bug.
    Last edited by oc666; 10-11-2009 at 04:29 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. Inside a Zend_Form object, can I get a reference to the current controller?
    By mesh2005 in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 01-28-2010, 08:56 AM
  2. Need a small help with Dojo form with TabContainer
    By SantaFox in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 01-10-2010, 05:54 PM
  3. Zend_Form, Jquery, Ajax, validation
    By MeroeKush in forum Model-View-Controller (MVC)
    Replies: 0
    Last Post: 11-28-2009, 06:10 AM
  4. Dynamic select boxes with Zend_Form and JQuery
    By topcatxx in forum General Q&A on Zend Framework
    Replies: 2
    Last Post: 10-30-2009, 01:22 PM
  5. DoJo TabContainer Decorator
    By altergothen in forum Core Infrastructure
    Replies: 0
    Last Post: 03-10-2009, 01:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •