Closed (fixed)
Project:
Drupal core
Version:
6.0
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Feb 2008 at 21:01 UTC
Updated:
19 May 2008 at 22:31 UTC
I've got the following code. It works, the fields shows up, but there's no default value, EVER.
function entity_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'entity_node_form') {
$node = $form['#node'];
$form['contact']['entity_telnum'] = array(
'#type' => 'textfield',
'#title' => t('Tel. Number'),
'#default_value' => isset($node->entity_contacts['Tel. Num']) ? $node->entity_contacts['Tel. Num] : 'NO DEFAULT',
'#description' => t('The telephone number of the entity')
);
}
A var_dump of $node->entity_contacts['Tel. Num'] gives string(10) "0123456789"
Comments
Comment #1
scoutbaker commentedMarked http://drupal.org/node/226650 as a duplicate.
Comment #2
jrgns commentedThis might be because of firefox's feature were it retains form information during a refresh.
When I initialy coded the form, I didn't add a default value. I then added a default value, and pressed control-R in firefox. Because the value for the textfield was an empty string, firefox replaced the value given by drupal with the "entered" value, an empty string.
By just going to the address (control-d, enter), the default value should show up.
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.