2012-09-18 3 views
1

내 사용자 정의 등록 양식 모듈은 새로운 사용자가 하나 이상의 도시를 선택할 수있는 선택 필드를 제공합니다. 나의 수색에서, 나는에서 당길 어떤보기도 찾아 내지 않았다. 예를 들어, 저장 될 도시 키가 20과 53 인 경우 'field_city'=> 다음 코드에서와 같이 표시되어야하는 예제가 있습니까?체크 상자 또는 선택 필드와 같은 여러 선택 필드가있는 user_save()

$edit = array(
    'name' => 'tester', 
    'pass' => user_password(), 
    'mail' => '[email protected]', 
    'status' => 0, 
    'init' => '[email protected]', 
    'access' => REQUEST_TIME, 
    'field_city' => , 
    'field_zip_postal_code' => array(LANGUAGE_NONE => array(array('value' => '12345'))), 
    'field_gender' => array(LANGUAGE_NONE => array(array('value' => 'Male'))), 
); 

user_save(drupal_anonymous_user(), $edit); 

답변

1

나는 이것을 스스로 알아 낸 것입니다. Taxonomy 용어 참조의 경우 누구에게나 도움이되는 경우 열 이름은 'tid'이며 다른 필드의 'value'가 아닙니다. I는 다음에 등록 코드를 변경 다음 'foreach는'루프

$edit = array(
    'name' => $form_state['step_information'][2]['stored_values']['name'], 
    'pass' => user_password(), 
    'mail' => $form_state['step_information'][2]['stored_values']['email'], 
    'status' => 0, 
    'init' => $form_state['step_information'][2]['stored_values']['email'], 
    'access' => REQUEST_TIME, 
    'field_zip_postal_code' => array(LANGUAGE_NONE => array(array('value' => $form_state['step_information'][3]['stored_values']['postal_code']))), 
    'field_gender' => array(LANGUAGE_NONE => array(array('value' => $form_state['step_information'][3]['stored_values']['gender']))), 
); 

foreach(array_keys($form_state['step_information'][1]['stored_values']['cities']) as $key => $val) { 
    $edit['field_city'][LANGUAGE_NONE][$key] = array('tid' => $val); 
} 

$new_account = user_save(drupal_anonymous_user(), $edit); 

'$ 키'은 '델타'항목에 저장됩니다 한 기수 (0, 1, 2, ...) 인 '$ val'은 도시의 ID입니다.

관련 문제