2012-05-14 7 views

답변

5

다음 코드이 작동

$myField_name = "NEW_FIELD_NAME"; 
    if(!field_info_field($myField_name)) // check if the field already exists. 
    { 
     $field = array(
      'field_name' => $myField_name, 
      'type'   => 'text', 
     ); 
     field_create_field($field); 

     $field_instance = array(
      'field_name' => $myField_name, 
      'entity_type' => 'user', // change this to 'node' to add attach the field to a node 
      'bundle'  => 'user', // if chosen 'node', type here the machine name of the content type. e.g. 'page' 
      'label'   => t('Field Label'), 
      'description' => t(''), 
      'widget'  => array(
       'type'  => 'text_textfield', 
       'weight' => 10, 
      ), 
      'formatter'  => array(
       'label'  => t('field formatter label'), 
       'format' => 'text_default' 
      ), 
      'settings'  => array(
      ) 
     ); 
     field_create_instance($field_instance); 

희망 ... 무하마드을 따르도록하십시오.

+0

덕분에 내가이 D7에서 나를 위해 일하고있다 그것을 – aladein

+0

를하려고합니다 - 감사합니다. –