Tag Archive | zend_form

Zend_Form – form tag in view

I have seen questions about how to get the form tag in a view for the form that is being used as an alternative to rendering the whole form.

I had a project a while back that I did not want to render the form but wanted to just render each element individually so that the designer could manage the CSS and general structure of the HTML. This was not a real problem in that it is rather easy to render each element on its own using

<?php echo $this->form->elementName->render(); ?> 

for each of the elements. With ZF1, doing the view this way tends to lead to people entering the opening and closing form tags manually like so

<form action="/controllerName/actionName" method="post">
    <?php echo $this->form->elementName->render(); ?>

which means they lose out on the OOP factor of that part of Zend_Form.

Continue reading

Some AJAX Zend style with JQUERY

I recently had the opportunity to work on a piece of code that was to accept a couple of values based on a couple of drop-down selectors. The second of the selectors needed to be relative to the value selected in the first one. This was part of a project that uses the Zend Framework. In order to not compromise my NDA, I am changing the particulars, but the nature of the task remains true. To that end, I will start by setting the environment. As stated, I am using the Zend Framework and implementing the MVC design pattern that ZF is known for. I am using the Zend_Layout extension and have the standard application/layouts/scripts folder with a “layout.phtml” file containing my overall layout. I am using just the Controller/Action setup rather than the Module/Controller/Action one, so if you are utilizing modules, then you will need to adjust this to your environment. I also use Zend_Form to create my form input and you will see some example code based on this a little later that will show two drop-down selectors defined on a form. The first drop-down selector will be called Category and the second drop-down selector will be called SubCategory. I know, how original! So, now that the background is laid out, lets start by defining the solution I am setting out to accomplish here.

Continue reading