FormElementManager and InputFilterManager

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FormElementManager and InputFilterManager

Ralf Eggert
Hi,

I am using hierarchical input filter classes and hierarchical forms with
fieldsets.

When I configure a fieldset for the form element manager, I can use
these lines to add the fieldset in the init() method of the form:

class ProductForm extends Form
{
    public function init()
    {
        $this->add(array(
            'type'       => 'Part4\ProductPriceFieldset',
            'name'       => 'price',
        ));
    }
}

When I configure an input filter for the input filter manager, I need to
use these lines to build a hierarchical input filter within the init()
method of the input filter:

class ProductFilter extends InputFilter
{
    public function init()
    {
        $this->add(
            array('type' => 'Part4\ProductPriceFilter'),
            'price'
        );
    }
}

When I want to use the same approach, like these lines I get an
"Zend\InputFilter\Factory::createInput expects an array or Traversable;
received "string"" error.

class ProductFilter extends InputFilter
{
    public function init()
    {
        $this->add(array(
            'type' => 'Part4\ProductPriceFilter',
            'name' => 'price'
        ));
    }
}

Is this a bug or a feature?

Thanks and regards,

Ralf
Reply | Threaded
Open this post in threaded view
|

Re: FormElementManager and InputFilterManager

bakura
This post has NOT been accepted by the mailing list yet.
I don't understand the question.

You receive the error when doing the last one?

class ProductFilter extends InputFilter 

    public function init() 
    { 
        $this->add(array( 
            'type' => 'Part4\ProductPriceFilter', 
            'name' => 'price' 
        )); 
    } 

It indeed looks good to me and should work. The second parameter of the "add" method in InputFilter is for setting the name but it's not needed if you have the "name" attribute in the specification.


Le 14 juil. 2013 à 15:46, Ralf Eggert [via Zend Framework Community] <[hidden email]> a écrit :

Hi,

I am using hierarchical input filter classes and hierarchical forms with
fieldsets.

When I configure a fieldset for the form element manager, I can use
these lines to add the fieldset in the init() method of the form:

class ProductForm extends Form
{
    public function init()
    {
        $this->add(array(
            'type'       => 'Part4\ProductPriceFieldset',
            'name'       => 'price',
        ));
    }
}

When I configure an input filter for the input filter manager, I need to
use these lines to build a hierarchical input filter within the init()
method of the input filter:

class ProductFilter extends InputFilter
{
    public function init()
    {
        $this->add(
            array('type' => 'Part4\ProductPriceFilter'),
            'price'
        );
    }
}

When I want to use the same approach, like these lines I get an
"Zend\InputFilter\Factory::createInput expects an array or Traversable;
received "string"" error.

class ProductFilter extends InputFilter
{
    public function init()
    {
        $this->add(array(
            'type' => 'Part4\ProductPriceFilter',
            'name' => 'price'
        ));
    }
}

Is this a bug or a feature?

Thanks and regards,

Ralf



If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/FormElementManager-and-InputFilterManager-tp4660573.html
To start a new topic under ZF Contributor, email [hidden email]
To unsubscribe from ZF Contributor, click here.
NAML