2011-10-04 82 views
0

如果選中一個cck單選框,我想打印「yes,checked」等內容。 單開/關複選框允許值爲yes和yes。如果單個複選框字段被選中,Drupal打印

複選框的信息是 -

<input type="checkbox" class="form-checkbox" checked="checked" value="yes" 
    id="edit-field-billing-terms-value" name="field_billing_terms[value]"> 

我想,以及與此代碼的修改失敗 -

<?php 
    $node->field_billing_terms[value] . '<br />'; 
    if($node->field_billing_terms[value] == 'yes') { 
     print "yes, checked"; 
    } 
?> 

有人可以給我一些指點我要去哪裏錯了嗎?如果需要,可以提供更多信息。

回答

1

字段通常在當連接到節點對象從零開始的數組,這應該解決您的問題:

$node->field_billing_terms[0]['value'] . '<br />'; 
if($node->field_billing_terms[0]['value'] == 'yes') { 
    print "yes, checked"; 
} 
+0

哇,這是快!萬分感謝!作品! – winchendonsprings

相關問題