나는 며칠 동안 붙어있어 누군가가 나를 도울 수 있기를 바랍니다. 다른 노드에 연결하는 모듈을 작성 중입니다. 그러나 모듈을 코딩하는 연습을하고 싶습니다. 그러나 다른 모듈을 참조하려고했으나 어떤 문제도 발견 할 수 없습니다.Drupal 7 필드 다중 값 삭제 및 표시
모듈을 추가 한 후 사용자 정의 노드 유형의 필드를 활성화하고 다중 값 허용을 선택합니다. 해당 콘텐츠 형식의 콘텐츠를 추가 할 때 두 개의 필드 대신 하나가 나타나고 추가 필드를 추가하면 삭제할 수 없습니다. 누군가가 나에게 그것을 고치는 방법에 대한 어떤 방향을 줄 수 있기를 바랍니다. 아래 문제의 스크린 샷을 포함 시켰습니다. 나는 또한 삭제 버튼/추가 항목을 삭제하는 방법을 추가하고자합니다. 수 일간의 연구 끝에, 나는 그것을 할 수있는 드루팔 (drupal) 방법을 찾을 수 없습니다.
아래는 내가 belong_to_relation.install
에 대한 참조 추가 코드입니다, 나는이 belong_to_relation.module를 들어
function belong_to_relation_field_schema ($field) {
if ($field['type'] == 'belong_to_relation') {
// Declare fields in the db
$columns = array (
'to_node_type' => array (
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'The relation id from the belong_to_relation table',
),
'to_node_nid' => array (
'type' => 'int',
'not null' => FALSE,
'description' => 'the node id of the to node',
),
'extended_node_nid' => array (
'type' => 'int',
'not null' => FALSE,
'description' => 'the node id of the extended field node',
),
);
return array (
'columns' => $columns,
'indexes' => array(),
);
}
}
다음, 나는 현재 드루팔 7.7에서 실행하고 다음
function belong_to_relation_field_info() {
return array (
'belong_to_relation_reference' => array (
'label' => t("Belong to Relation Node Reference"),
'description' => t('This field stores a node reference to a node of another content type'),
'default_widget' => 'belong_to_relation_reference_widget',
'default_formatter' => 'belong_to_relation_reference_formatter',
),
);
}
function belong_to_relation_field_widget_info() {
return array (
'belong_to_relation_reference_widget' => array (
'label' => t('Default'),
'field types' => array ('belong_to_relation_reference'),
),
);
}
function belong_to_relation_field_widget_form (&$form, &$form_state, $field,
$instance, $langcode, $items,
$delta, $element) {
$element += array(
'#type' => 'fieldset',
'#tree' => true
);
$element['to_node_type'] = array (
'#type' => 'select',
'#title' => t('Target Node Type'),
'#options' => array(),
'#default_value' => isset($item['to_node_type']) ? $item['to_node_type'] : NULL,
'#empty_option' => 'Select a Node type',
);
$element['to_node_nid'] = array (
'#type' => 'select',
'#title' => t('Target Node Type'),
'#options' => array(),
'#default_value' => isset($item['to_node_nid']) ? $item['to_node_nid'] : NULL,
'#empty_option' => 'Select a Node',
);
$element['extended_node_nid'] = array (
'#type' => 'select',
'#title' => t('Target Node Type'),
'#options' => array(),
'#default_value' => isset($item['extended_node_nid']) ? $item['extended_node_nid'] : NULL,
'#empty_option' => 'Select a Node type',
);
return $element;
}
function belong_to_relation_field_is_empty ($item, $field) {
return FALSE;
}
function belong_to_relation_field_formatter_info() {
return array (
'belong_to_relation_reference_formatter' => array (
'label' => t('Simple Belong To Relation Formatter'),
'field types' => array ('belong_to_relation_reference'),
),
);
}
를 추가 추가 MAMP에.
해결에
if ($field['type'] == 'belong_to_relation')
라인을 삭제해야의 경우 ($ 필드 [ '유형'] == 'belong_to_relation')을 삭제해야 install in install – user866807이 질문에 대한 대답으로 자신의 답변을 게시 할 수 있습니다. http://meta.stackexchange.com/questions/83432/what-is-the-best-way-to-answer-your-own-question – nmc