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

scoutbaker’s picture

Status: Active » Closed (duplicate)