[development] Weird behavior on #default_value

Tao Starbow starbow at citris-uc.org
Thu Jan 24 17:03:54 UTC 2008


Probably means your #value is getting set through some other mechanism.  
FormAPI can be pretty subtle at times.  I seem to remember having a 
similar problem when I was playing around with #multistep, but I don't 
remember how I fixed it.

good luck,
-tao

Feijó wrote:
> John,
>
> I only used #value to test my array content!! I do not intent to use both
>
> With #value, it shows up, when I change to #default_value, the 
> information is gone!!!
>
> its clear now? :)
>
>
> thanks!!
> Feijó
>
> John VanDyk escreveu:
>> If #value is set, #default_value will be ineffective. From form.inc:
>>
>>       if (!isset($form['#value'])) {
>>         $function = $form['#type'] . '_value';
>>         if (function_exists($function)) {
>>           $function($form);
>>         }
>>         else {
>>           $form['#value'] = isset($form['#default_value']) ? 
>> $form['#default_value'] : '';
>>         }
>>       }
>>
>> Because the form is built multiple times, this can be confusing.
>>
>>> I already try with print_r !
>>>
>>> it shows the content "array(['name'] => 'name test')" in 
>>> #description and #value, but never on #default_value
>>>
>>> The name field is varchar(50), with 'name test'.  Just it.
>>>
>>> Yesterday a PHP expert was here, he take a look at this, we try a 
>>> lot of possibilities, no clue whatsoever
>>>
>>> It cant be explained :)
>>>
>>>
>>> Jakob Petsovits escreveu:
>>>
>>>> On Thursday, 24. January 2008, Feijó wrote:
>>>>
>>>>
>>>>>  If I try
>>>>>      '#default_value' => 'test ' . $row['name'],
>>>>>
>>>>>  only test apears!
>>>>>   
>>>>
>>>> Imho, that behaviour suggests that something is wrong with 
>>>> $row['name'] and
>>>> less with Form API itself. (Because string concatenation fails even 
>>>> before
>>>> the Form API gets the value passed over.)
>>>>
>>>> Not sure, but maybe print_r($row) and/or gettype($row['name']) 
>>>> reveals some
>>>> useful information...
>>>>
>>


More information about the development mailing list