| 
 | 
  Maslov Ivan - 2006-12-22 11:49:51  
<?php 
 
error_reporting(E_ALL); // report all errors 
 
define('SMARTY_DIR', "./../includes/engine/Smarty/"); 
 
require_once(SMARTY_DIR . "forms.php"); 
 
$formContent = new form_class; 
$formContent->encoding	= "windows-1251"; 
$formContent->NAME		= "formContent"; 
$formContent->METHOD	= "POST"; 
$formContent->ACTION	= ""; 
$formContent->debug		= "trigger_error"; 
 
$formContent->AddInput(array( 
	"TYPE"=>"hidden", 
	"NAME"=>"doit", 
	"VALUE"=>1 
)); 
 
 
$_GET['pid'] = 10; 
$formContent->AddInput(array( 
	"TYPE"=>"hidden", 
	"NAME"=>"pid", 
	"VALUE"=>$_GET['pid'], 
)); 
 
 
 
 
echo "<pre>"; 
print_r($formContent->inputs['pid']); 
/* 
Array 
( 
    [NAME] => pid 
    [TYPE] => hidden 
    [VALUE] => 10 
    [SubForm] => 
    [ClientValidate] => 0 
    [ServerValidate] => 0 
) 
*/ 
 
$formContent->LoadInputValues($formContent->WasSubmitted("doit")); 
print_r($formContent->inputs['pid']); 
/* 
Array 
( 
    [NAME] => pid 
    [TYPE] => hidden 
    [VALUE] =>  
    [SubForm] => 
    [ClientValidate] => 0 
    [ServerValidate] => 0 
) 
*/ 
 
/* 
forms.php,v 1.270 2006/12/20 
*/ 
 
var_dump(PHP_VERSION, PHP_OS); 
/* 
'5.2.0' (length=5) 
 
'WINNT' (length=5) 
*/ 
 
?> 
 
Куда делось VALUE????? 
 
  
  Manuel Lemos - 2006-12-22 19:58:48 -  In reply to message 1 from Maslov Ivan 
There seems to be nothing wrong with this. The class seems to be picking the pid input value from your POST variables when LoadInputValues is called, thus overriding the initial value. 
  
  Maslov Ivan - 2006-12-22 22:39:59 -  In reply to message 2 from Manuel Lemos 
In the given example POST has not occured. 
 
$_POST=$HTTP_POST_VAR=null 
  
  Maslov Ivan - 2006-12-22 22:41:09 -  In reply to message 3 from Maslov Ivan 
Take a set example, start and look, that it will return. 
  
  Manuel Lemos - 2006-12-23 02:19:45 -  In reply to message 4 from Maslov Ivan 
Take a look in your script and see if you are not setting a global variable named pid . 
  
  Maslov Ivan - 2006-12-23 11:50:30 -  In reply to message 5 from Manuel Lemos 
Error! 
 
$pid = 10; 
$formContent->AddInput(array( 
	"TYPE"=>"hidden", 
	"NAME"=>"pid", 
	"VALUE"=>$pid 
)); 
Result: 
Array 
( 
    [NAME] => pid 
    [TYPE] => hidden 
    [VALUE] =>  
    [SubForm] =>  
    [ClientValidate] => 0 
    [ServerValidate] => 0 
) 
------------------------------------- 
$pid = 10; 
$formContent->AddInput(array( 
	"TYPE"=>"hidden", 
	"NAME"=>"pid", 
	"VALUE"=>settype($pid, "string") 
)); 
Result: 
Array 
( 
    [NAME] => pid 
    [TYPE] => hidden 
    [VALUE] => 10 
    [SubForm] =>  
    [ClientValidate] => 0 
    [ServerValidate] => 0 
) 
 
Bug in: 
Function GetValue($variable,$file,$multiple=0) { 
... 
		if($multiple) 
		{... 
		} 
		else 
		{ 
!!!!!!!			if(GetType($value)!="string") 
				return(""); 
		} 
} 
 
  
  Maslov Ivan - 2006-12-23 12:07:15 -  In reply to message 6 from Maslov Ivan 
	Function GetValue($variable,$file,$multiple=0) 
	{ 
				var_dump($variable . "=". $_GET[$variable]. "(" . GetType($_GET[$variable]) . ")"); 
				if(IsSet($_GET[$variable])) 
				{ 
					$value=$_GET[$variable]; 
					break; 
				} 
...} 
Return: 
 
'module=contents(string)' (length=23) 
 
'action=new(string)' (length=18) 
 
'pid=3605(integer)' (length=17) 
 
Есть тип Integer!!! 
			if(GetType($value)!="string") 
				return(""); - Error!!!!!!!!!!!!!!!! 
 
 
 
 
  
  Manuel Lemos - 2006-12-23 17:19:34 -  In reply to message 7 from Maslov Ivan 
There is no bug in GetValue. If you want to pass the pid variable via your forms, you should not use any GET variables or global variables with the same name to not interfere with the form values. 
  
  Maslov Ivan - 2006-12-23 20:55:18 -  In reply to message 8 from Manuel Lemos 
I have understood your idea. Thanks. I shall try further. And that that type Integer, instead of String comes back? 
  
  Maslov Ivan - 2006-12-24 08:30:19 -  In reply to message 9 from Maslov Ivan 
Can so more correctly: 
if(GetType($value)!="string" && GetType($value)!="integer") 
return("");  
  
   |