Skip to content

[2.0.x] Setting form element name to "value" produces BadMethodCallException during render #10398

Closed
@cinu

Description

Setting form element name to "value" produces BadMethodCallException (Wrong number of parameters) during render.

Reproduction code:

<?php
$di = new \Phalcon\DI\FactoryDefault();

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;

class FormTest extends Form
{
    public function initialize()
    {
        $this->add(new Text("value"));
        $this->add(new Text("value2"));
    }
}

$f=new FormTest();
echo $f->render('value2'); // works
echo $f->render('value'); // exception

/*
output:

<input type="text" id="value2" name="value2" />PHP Fatal error:  Uncaught exception 'BadMethodCallException' with message 'Wrong number of parameters' in /.../test.php:18
Stack trace:
#0 [internal function]: Phalcon\Forms\Form->getValue()
#1 [internal function]: Phalcon\Forms\Form->getValue('value')
#2 [internal function]: Phalcon\Forms\Element->getValue()
#3 [internal function]: Phalcon\Forms\Element->prepareAttributes(NULL)
#4 [internal function]: Phalcon\Forms\Element\Text->render(NULL)
#5 /.../test.php(18): Phalcon\Forms\Form->render('value')
#6 {main}
  thrown in /.../test.php on line 18

PHP: 5.6.7-1 (debian)
Phalcon: 2.0.1

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions