Zend Form: How do I make it bend to my will?

后端 未结 14 1500
你的背包
你的背包 2021-01-29 18:53

I\'ve read the manual many times, I\'ve scoured the posts offered by Google on the subject, I have even bought a couple of books that deal with ZF. Now, why am I still confused?

14条回答
  •  伪装坚强ぢ
    2021-01-29 19:40

    You probably have solved this by now, but I've been doing some work and needed a similar solution.

    form->getSubform('subform'); 
    foreach ($subform as $key => $value) {
    //some markup and custom code here
        print $value;
    //some markup and custom code here
    
    }
    ?>
    

    within the foreach loop, you can add table markup. If you've named your keys for your table rows appropriately, they should match up with the form keys. You could even use a loop that grabs the appropriate subform by key, or even an element by a key. you could skip the foreach loop if you know the keys, and simply say print $subform['somekey']; assuming you set the main form by saying $form->setIsArray(true); (not sure if that last part is strictly necessary, but for complicated forms, it should be set like that anyway.

    I removed the default decorators so I could have complete control of printing within each element. Zend_Form ought to have a built-in method for grabbing individual elements a little more easily.. but I think this works pretty well.

    Hope that's helpful to someone!

提交回复
热议问题