Hello,
I'm not sure what is the expected behavior of this but I have found this
issue...
I have a form Client that includes a subform "phone" (holds the phone
service of the client)
When setDefaults is called to fill the default values of it's form and
subforms a "collision" occurs between the name of the subform and the
clientinfo(form)- phone number (field) where this dissolveArrayValue is used
to check if there are values that belong to the form X and results in the
following error:
Catchable fatal error: Argument 1 passed to Zend_Form::setDefaults() must be
an array, string given, called in /usr/local/lib/php/Zend/Form.php on line
1285 and defined in /usr/local/lib/php/Zend/Form.php on line 1261
The code bellow shows the problem where "0" is returned instead of the
array... Am I doing anything wrong or is the logic broken?
To overcome this problem I have just changed the subform name witch avoids
the issue.
<?php
function dissolveArrayValue( $value, $arrayPath )
{
while ( $arrayPos = strpos( $arrayPath, '[')) {
$arrayKey = trim( substr( $arrayPath, 0, $arrayPos), ']');
if ( isset( $value[$arrayKey])) {
$value = $value[$arrayKey];
}
$arrayPath = trim( substr( $arrayPath, $arrayPos + 1), ']');
}
if ( isset( $value[$arrayPath])) {
$value = $value[$arrayPath];
}
return $value;
}
$defaults = array ( 'idclient' => '2', 'name' => 'Java', 'contract' =>
'019191',
'node' => 'LA01', 'mobile' => '0', 'phone' => '0', 'email' => '', 'state'
=>
'active', 'datain' => '2012-04-03 23:31:41');
$value = dissolveArrayValue( $defaults , "phone");
var_dump( $value );
$value = dissolveArrayValue( $defaults, "internet" );
var_dump( $value );
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF1-Zend-Form-dissolveArrayValue-value-arrayPath-issue-tp4574234p4574234.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]