Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-13-2008, 05:34 PM
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Zend_Form/Zend_View with no MCV?

Hi, I'm trying to use the Zend_Form component in a script which does not use the full mcv structure.

When I try to render the form, it says it needs Zend_View.

I have heard that Zend_View can be used standalone, is this true? I have searched for instructions but have had no luck.

If anyone knows how to do this please let me know.

Thank You
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-13-2008, 07:02 PM
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

Solved it myself! After messing around with the code I came up with this - which works.

Code:
<?php

// Setup Include Paths
define('ROOT_DIR', dirname(__FILE__));
set_include_path(
	  ROOT_DIR . '/library' . PATH_SEPARATOR
	. ini_get('include_path') . PATH_SEPARATOR
);

// Load Classes On Demand
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoLoad();

// Setup View
$view = new Zend_View();
$view->setScriptPath('views');

// Setup Config
$config = new Zend_Config_Ini(ROOT_DIR . '/config/config.ini');

// Setup Form
$form = new Zend_Form($config->form1);

// Output Form
$view->form = $form->render($view);
echo $view->render('view.php');
The last two lines were the difficult part. You must use the Zend_Form::render() method, passing it your view object, then render the actual view.

You're welcome

Last edited by c0mrade : 04-13-2008 at 08:55 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:11 PM.