FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=20071&edit=1

  ID: 20071
  Updated by: loki_angel@mail.ru
  Reported By: loki_angel at mail dot ru
  Summary: Validation problem with default value
  Status: Bogus
  Type: Bug
  Package: HTML_QuickForm2
  Package Version: 2.0.0
  PHP Version: Irrelevant
  Roadmap Versions:
  New Comment:

But input field could be completely deleted through Firebug for example.
In this case
not valid form validates as valid. Also data could be sended by script -
not by browser.


Previous Comments:
------------------------------------------------------------------------

[2013-09-22 14:07:20] avb

-Status: Open
+Status: Bogus
null value can't appear in $_POST unless you put it there manually. If
you run the code with 'first' => '', which is the actual submit value
for empty field, validation will run as expected.

------------------------------------------------------------------------

[2013-09-22 12:43:42] loki

Description:
------------
Fields with default values has a problem with validation

Test script:
---------------
$form = new HTML_QuickForm2(null, 'post');

$first=$form->addElement('text', 'first', array('value'=>111));
$second=$form->addElement('text', 'second');

$first->addRule(
  'callback',
  'Error in field 1',
  array('callback'=>'checkField1',
  'arguments'=>array(false))
);

$second->addRule(
  'required',
  'Error in field 2'
);

function checkField1($value) {
  return 111==$value;
}

if ($form->validate()) {
  echo 'valid';
} else {
  echo 'not valid';
}

//recived post data
$_POST=array( 'first'=>222, 'second'=>'some value' ); //not valid
$_POST=array( 'first'=>null, 'second'=>'some value' ); //valid
$_POST=array( 'second'=>'some value' ); //valid

------------------------------------------------------------------------

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedSep 22, '13 at 12:01p
activeSep 22, '13 at 2:46p
posts2
users2
websitepear.php.net

2 users in discussion

Borz_off: 1 post Loki_angel: 1 post

People

Translate

site design / logo © 2022 Grokbase