You could create a view helper that loops through the form's elements to
generate a basic view.

In its simplest form, it could be something like this:

class Default_View_Helper_FormView extends Zend_View_Helper_Abstract
{
    public function formView(Zend_Form $form)
    {
        $html = "<dl>";
        foreach ($form->getElements as $element) {
            $html .= "<dt>{$this->escape($element->getLabel())}</dt>";
            $html .= "<dd>{$this->escape($element->getValue())}</dd>";
        }
        $html .= "</dl>";
        return $html;
    }
}

Another option would be use a partialLoop over the elements, but a view
helper would be faster.

--
Hector


On Tue, Mar 30, 2010 at 9:11 AM, Keyne <[email protected]> wrote:

>
>
>
> I was wondering if is there an easy way to generate views from form objects
> when dealing with CRUDs.
>
> I mean, when we have these options: VIEW | EDIT | DELETE I want my VIEW
> option like EDIT option, but without form elements, just the values.
>
> This will minimize so much the time spent to create these views.
>
> Someone knowks something like that?
>
>
> (Read more:
>
> http://stackoverflow.com/questions/2298475/is-there-a-way-to-generate-views-from-zend-form-read-only
> )
> --
> View this message in context:
> http://n4.nabble.com/Is-there-a-way-to-generate-views-from-Zend-Form-tp1745449p1745449.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

Reply via email to