when use form inputFilter getMessages return empty #5164

Closed
wohugb opened this Issue Sep 24, 2013 · 3 comments

Comments

Projects
None yet
5 participants

wohugb commented Sep 24, 2013

If there have not riquried elments,when required elements are ok, $form->isValid() return false,but $form->getMessages() return empty!

Member

Ocramius commented Sep 24, 2013

@wohugb this is the issue tracker for ZF. If you are encountering difficulties and didn't yet identify the problem as a ZF bug, then please don't post an issue, and instead ask on IRC or the mailing list or stackoverflow.

Contributor

ThaDafinser commented Mar 6, 2014

@wohugb @Ocramius i think i know what's that problem....

<?php
namespace MyModule\Form;

use Zend\Form\Fieldset;
use Zend\Form\Element;
use Zend\InputFilter\InputFilterProviderInterface;

class SomeFieldset extends Fieldset implements InputFilterProviderInterface
{

    public function init()
    {
        parent::setName('entry');

        $id = new Element\Hidden('id');
        $this->add($id);
    }

    public function getInputFilterSpecification()
    {
        $filter = array(

            'id' => array(
                'required' => false
            ),

            'description' => array(
                'required' => true
            )
        );

        return $filter;
    }
}

If will fail, because you say "description" is required (but not available).
Since the form cannot apply the error to an element, the message is empty...

-> Had that error also some time ago (is really hard to fine out, when you dont know how to search for this)

Member

adamlundrigan commented Oct 22, 2015

Duplicate of #4017. See this comment over there for rationale of why it's closed as not an issue.

@Maks3w this can be closed

@Maks3w Maks3w closed this Oct 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment