[TYPO3-project-formidable] Bug in validation using a userObj

Jerome Schneider j.schneider at ameos.com
Mon Jun 18 16:03:46 CEST 2007


Hello Oliver,

You're right this is a bug.

The problem is that an array of parameters is expected in _callUserObj, 
and we're passing a string.

In mainvalidator, at line 96,

http://test.kunstvaerker.dk/html/classformidable__mainvalidator.html#l00096

I think the best fix would be to wrap $value in an array, with "value" 
as a key in the array

so that the line becomes this:

if(($bExecute = $this->oForm->_callUserObj($aConf, array("value" => 
$value))) !== TRUE) {


With this modification, in your function, debug now gives:

+--foo----------------------+
+value       + entered value+
+elementname + company      +

So this solves the problem.

The correction is effective in SVN on rev 65.

Regards,
Jerome Schneider




Oliver Klee a écrit :
> Hi,
> 
> I think I've just stumbled upon a bug in the standard validator using a
> userobj (in FORMidable 0.7.0).
> 
> My test code looks like this:
> 
> <validators>
> 	<validator:STANDARD>
> 		<userobj>
> 			<extension>this</extension>
> 			<method>isFieldFilledInOrNotRequired</method>
> 			<params>
> 				<param name="elementname" value="company" />
> 			</params>
> 		
> <message>LLL:EXT:onetimeaccount/pi1/locallang.xml:message_company</message>
> 		</userobj>
> 	</validator:STANDARD>
> </validators>
> 
> ...
> 
> function isFieldFilledInOrNotRequired($foo) {
> 	t3lib_div::debug($foo, 'foo');
> 	return false;
> }
> 
> So I'd expect the following output when "hello" is entered into the
> corresponding field:
> 
> foo
> elementname | company
> 
> 
> Instead, I see the following:
> 
> foo
> |cello|
> 
> So that is the input, but the first letter is replaced by the first
> letter of the parameter value.
> 
> 
> I think the problem is the following:
> 
> 1. tx_ameosformidable::_callUserObj expects the parameters as the second
> function parameter:
> 
> function _callUserObj($aUserobj, $aParams = array(), $aItems = FALSE,
> $oRef = FALSE, $bAddDots = TRUE) {
> 
> 2. ... but formidable_mainvalidator::_doTheMagic provides the parameters
> as the first function parameter, providing the entered value instead of
> the expected parameters:
> 
> if(($mUserObj = $this->oForm->_navconf("/userobj", $aConf)) !== FALSE) {
> 				if(($bExecute = $this->oForm->_callUserObj($aConf, $value)) !== TRUE) {
> 
> 
> So I suppose this function call in the validator class needs to be fixed.
> 
> Regards,
> 
> 
> Oliver


More information about the TYPO3-project-formidable mailing list