0
votes

My Custom Zend Form Filter Classes are not being loaded.

The Custom Filter Class name is: SF_Filter_AlnumDashes and it resides into: library/SF/Filter/AlnumDashes.php.

I have configured autoloading for the "SF_" namespace into application.ini:

autoloadernamespaces[] = "SF_"

But when I try to load the Class during Zend Form creation I get error that the class coudn't be found: Fatal error: Class 'AlnumDashesUnderscore' not found in...

Here is the code that is causing the error in the Zend Form class:

class Admin_Form_Product_Generalinfo extends SF_Form_Abstract {

    public function init() {

        //set ID Attribute on the form element
        $this->setAttrib('id', 'product_general_info');

        $elementPrefixPaths = array(
                array(
                    array(
                        'prefix' => 'SF_Filter', 
                        'path' => 'SF/Filter/', // 'application/validators' in your case
                        'type' => 'filter',
                    )
                )
            ); 
        $this->addElementPrefixPaths($elementPrefixPaths);

    $this->addElement('text', 'title', array(

            'filters' => array('StringTrim', 'StripTags'),
            'validators' => array(
        array('StringLength', true, array(2, 250)),
            ),
            'required' => true,
            'label' => 'Title',
            'attribs' => array(
                'id' => 'title',
                'class' => 'inputbox'
             )

    ));

        $this->getElement('title')->addFilter(array(new AlnumDashesUnderscore(), array(1)));

}

I have other classes into "SF_" Namespace that get load successfully, calling them from Controllers with no problem.

1

1 Answers

0
votes

The class is defined as SF_Filter_AlnumDashes, but you're trying to create a new instance of AlnumDashesUnderscore. These class names need to match:

$this->getElement('title')->addFilter(array(new SF_Filter_AlnumDashes(), array(1)));