Zend Formlar Modülü Yolları Dahil

2 Cevap php

Ben Zend 1.8.4 kullanıyorum ve basit bir form testi kuruyorum. Benim form sınıf '. / Uygulama / formları / SectorSearch.php' bulunan ve sınıf adıdır

<?php
class Form_SectorSearch extends Zend_Form
{...}

Benim denetleyicisi init () yöntemi yeni bir form oluşturur

<?php
class SectorController extends Zend_Controller_Action
{
    function init()
    {
        $this->initView();
	    $form = new Form_SectorSearch(array(
		    'method' => '/public/sector/search',
		    'action' => 'post'));
        $this->view->form = $form;
    }
..
}

Ama bu hatayı alıyorum

Warning: Zend_Loader_Autoloader_Resource::include(/home/poconnell/projects/bhaa/application/forms/SectorSearch.php) [zend-loader-autoloader-resource.include]: failed to open stream: No such file or directory in /home/poconnell/projects/bhaa/library/Zend/Loader/Autoloader/Resource.php on line 178

Warning: Zend_Loader_Autoloader_Resource::include() [function.include]: Failed opening '/home/poconnell/projects/bhaa/application/forms/SectorSearch.php' for inclusion (include_path='/home/poconnell/projects/bhaa/library:/home/poconnell/projects/bhaa/application:.:/usr/share/php:/usr/share/pear') in /home/poconnell/projects/bhaa/library/Zend/Loader/Autoloader/Resource.php on line 178

Fatal error: Class 'Form_SectorSearch' not found in /home/poconnell/projects/bhaa/application/controllers/SectorController.php on line 19

Ben sınıf dahil yolda olduğunu% 100 eminim.

Ben bu bir bootstraping sorun olduğunu düşünüyorum, ve bu ben varsayılan modül yüklenirken ediyorum nasıl

protected function _initAutoload()
{   
    //Zend_Loader_Autoloader_Resource  - Zend_Application_Module_Autoloader
    $moduleLoader = new Zend_Application_Module_Autoloader(array(
        'namespace' => '', 
        'basePath' => APPLICATION_PATH
    ));
    return $moduleLoader;
}

Autloading modular forms & models in Zend Framework 1.8 tarafından tavsiye olarak ben bile, bu desen kullanarak çalıştı

protected function _initAutoload()
{   
    //Zend_Loader_Autoloader_Resource  - Zend_Application_Module_Autoloader
    $moduleLoader = new Zend_Application_Module_Autoloader(array(
        'namespace' => '', 
        'basePath' => APPLICATION_PATH,
        'resourceTypes' => array (
			'form' => array(
			'path' => 'forms',
			'namespace' => 'Form'))
    );
    return $moduleLoader;
}

ama hiçbir sevinç. herhangi bir fikir?

2 Cevap

Benim bootstrap.php dosyasına aşağıdaki eklendi

protected function _initAutoload()
    {
        $autoloader = new Zend_Loader_Autoloader_Resource(array(
            'namespace' => '',
            'basePath' => APPLICATION_PATH,
            'resourceTypes' => array(
                'form' => array(
                    'path' => 'forms',
                    'namespace' => 'Form',
                ),
                'model' => array(
                    'path' => 'models',
                    'namespace' => 'Model',
                ),
            )
        ));
        return $autoloader;
    }

ve şimdi çalışıyor, artık hiç hata .. lanet ben çalıştığını sevindim, ben neredeyse deli gidiyordu .. :)

Zend Framework klasörler gibi sınıf isimleri çizgi yorumlar. Elle dahil yoluna başvuru / formları klasör eklerseniz, o zaman sınıf FormSectorSearch (ve dosya FormSectorSearch.php) yerine Form_SectorSearch bir isim olmalıdır. Aksi takdirde sadece ekleme yolu uygulama klasör eklemek ve daha sonra yerine formların klasör Formu adında olacaktır.