2011-07-29 12 views
0

私は数日間立ち往生しており、誰かが私を助けてくれることを願っています。 私は別のノードにリンクするモジュールを書いています(このようなモジュールは存在しますが、モジュールのコーディングを練習したいと思いますが、他のモジュールを参照しようとしましたが問題は見つかりません)。Drupal 7フィールド複数の値を削除して表示する

モジュールを追加した後、私はカスタムノードタイプのフィールドをアクティブにし、複数の値を許可を選択します。コンテンツを追加すると(そのコンテンツタイプの)2つのフィールドが1つではなく表示され、追加のフィールドを追加すると削除できません。私は誰かが私にそれを修正する方法のいくつかの方向を与えることができることを願っています。私は以下の問題のスクリーンショットを含んでいます。私はまた、削除ボタン/余分なアイテムを削除する方法を追加することを望んでいます。数日間の研究の後、私はそれを行うための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(), 
); 
    } 

} 

を追加し、私は現在のDrupal 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で

+1

if ($field['type'] == 'belong_to_relation')行を削除する必要があり、もし($フィールド[ '型'] == 'belong_to_relation')を削除する必要があります.installのライン – user866807

+0

あなたはこの質問に受け入れられた答えとしてあなた自身の答えを掲示することができます。 http://meta.stackexchange.com/questions/83432/what-is-the-best-way-to-answer-your-own-question – nmc

答えて

0

OPが書いた:解決

を、.install

解決
+0

([コメントで回答し、コミュニティのwiki回答に変換しました]( http://meta.stackoverflow.com/questions/251597/question-with-no-answers-butissues-solved-in-the-comments?rq=1))。 –

関連する問題