[英]Cant find the error in the PHP code (The site is on Norwegian, but just read the code)
[英]Cant find the Error in this Php piece of code
我在此代碼上收到T_String錯誤,它在第二行($ form ['com ...)更准確地說,我根本看不出為什么。
function _maxlength_comment_type_form_alter(&$form, $form_state, $form_id) {
$form['comment']['comment_max_length'] = array(
'#type' => 'select',
'#title' => t('Maximum comment length'),
'#default_value' => variable_get('comment_max_length_'. $form['#node_type'] -> type, 160),
'#options'=> drupal_map_assoc(array(140,160,180,200)),
'#description' => t('numero maximo de caracteres permitidos.'),
'#weight' => -1,
);
我將這段代碼添加到Maxlength drupal模塊中。
可能是這部分:
'comment_max_length_'. $form['#node_type'] -> type
嘗試擺脫箭頭周圍的空格?
編輯-我不認為上面的代碼實際上是一個問題,盡管我仍然建議您刪除樣式的空格,但這顯然是您在執行此操作:
'comment_max_length_'. ($form['#node_type']->type)
而不是這樣:
('comment_max_length_' . $form['#node_type'])
您的代碼是有效的並且可以在My PC TM上運行 。
另一個編輯:
確保$form['comment']
也已定義。 也許在函數開始時添加它。
if (!isset($form['comment'])) $form['comment'] = array();
我可以看到兩個問題,上面提到的一個缺口,即箭頭的兩側都不能有空格:
'comment_max_length_'. $form['#node_type'] -> type
此外,它后面不應有逗號(因為它是數組中的最后一項):
'#weight' => -1,`
將那個巨大的陳述分解成更小的陳述怎么樣,以便您可以更好地指出問題所在?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.