Form annotation with capital letters #2741

Closed
chrvadala opened this Issue Oct 11, 2012 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

chrvadala commented Oct 11, 2012

Hi,
I think that there is a bug with form annotation builder.

If I use a variable that have a capital letter the hydrator ClassMethods doesn't work very well.
Here there is an example:
Can somebody check this problem?

<?php
namespace TestForm;

chdir(__DIR__ . '/../../../');

include_once 'init_autoloader.php';

use Zend\Form\Annotation as Form;

/**
* @Form\Name("customer")
* @Form\Hydrator("Zend\Stdlib\Hydrator\ClassMethods")
*/

class TestClass{

    /**
    * @Form\Type("Zend\Form\Element\Checkbox")
    * @Form\Filter({"name":"Boolean"})
    ***/
    protected $boolean;

    /**
     * @Form\Type("Zend\Form\Element\Checkbox")
     * @Form\Filter({"name":"Boolean"})
     ***/
    protected $booleanBoolean;

    /**
     * @Form\Type("Zend\Form\Element\Text")
     ***/
    protected $text;

    /**
     * @Form\Type("Zend\Form\Element\Text")
     ***/
    protected $textText;

    public function getBoolean() {return $this->boolean;}
    public function setBoolean($boolean) {$this->boolean = $boolean;}
    public function getBooleanBoolean() {return $this->booleanBoolean;}
    public function setBooleanBoolean($booleanBoolean) {$this->booleanBoolean = $booleanBoolean;}


    public function getTextText() { return $this->textText;}
    public function setTextText($textText) {$this->textText = $textText;}
    public function getText() { return $this->text;}
    public function setText($text) {$this->text = $text;}
}


$obj = new \TestForm\TestClass();
$obj->setBoolean(true);
$obj->setBooleanBoolean(true);
$obj->setText('hello');
$obj->setTextText('hello');


$builder = new \Zend\Form\Annotation\AnnotationBuilder();
$form = $builder->createForm('TestForm\TestClass');
$form->bind($obj);

var_dump($form->get('boolean')->isChecked());
var_dump($form->get('booleanBoolean')->isChecked()); //BUG
var_dump($form->get('text')->getValue());
var_dump($form->get('textText')->getValue()); //BUG
Contributor

bakura10 commented Nov 20, 2012

Did you try by providing a name to the element ?

/**
 * @Form\Type("Zend\Form\Element\Checkbox")
 * @Form\Name("booleanBoolean")
 * @Form\Filter({"name":"Boolean"})
 ***/
protected $booleanBoolean;
Contributor

chrvadala commented Nov 23, 2012

@bakura10 Thank you. I was wrong, I thought that this was an error.

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