2

我创建了一个包含多个文本字段的表单。文本字段从数据库中获取默认值。表格在表格中,但有些单元格消失了。这很奇怪,因为当我更改数据库中的某些值时,它们可能会出现。任何人都可以帮忙吗?

$matches = competition_entry_load(); 
    $form['namefield'] = array(
    '#type' => 'fieldset',
    '#title' => t('check'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  foreach ($matches as $key=>$entry) {
    $A1 = $entry->A1;   
    $AX = $entry->AX;
    $A2 = $entry->A2;
    $home_team = $entry->home_team;
    $away_team = $entry->away_team;


    $form['namefield'][$A1] = array(
    '#type' => 'textfield',
    '#default_value' => $A1,
    '#size' => 6,
    '#maxlength' => 6,
    '#prefix' => '<table border=0 cellspacing=30 celladding=30><tr><td><center>',
    '#suffix' => '</center></td>',
  ); 



    $form['namefield'][$AX] = array(
    '#type' => 'textfield',
    '#default_value' => $AX,
    '#size' => 4,
    '#maxlength' => 4,
    '#prefix' =>'<td><center>',
    '#suffix' => '</center></td>',
  ); 

    $form['namefield'][$A2] = array(
    '#type' => 'textfield',
    '#default_value' => $A2,
    '#title'=> t($A2),
    '#size' => 4,
    '#maxlength' => 4,
    '#prefix' =>'<td><center>',
    '#suffix' => '</center></td>',
  ); 

    $form['namefield'][$home_team] = array(
    '#type' => 'textfield',
    '#default_value' => $entry->home_team,
    '#size' => 15,
    '#maxlength' => 15,
    '#prefix' =>'<td><center>',
    '#suffix' => '</center></td>',
  ); 

    $form['namefield'][$away_team] = array(
    '#type' => 'textfield',
    '#default_value' => $entry->away_team,
    '#size' => 15,
    '#maxlength' => 15, 
    '#prefix' =>'<td><center>',
    '#suffix' => '</center></td>',
  );


    $form['namefield']['skorH_'.$home_team] = array(
    '#type' => 'textfield',
    '#size' => 1,
    '#maxlength' => 1,
    '#prefix' =>'<td><center>',
    '#suffix' => '</center></td>',
  ); 

    $form['namefield']['skorA_'.$home_team] = array(
    '#type' => 'textfield',
    '#size' => 1,
    '#maxlength' => 1,
    '#prefix' =>'<td><center>',
    '#suffix' => '</center></td></tr></table>',
  ); 
}

return $form;
}
4

1 回答 1

0

我认为错误在于您用作 $form 数组的键的变量值。如果在循环中 $A1、$A2 等的值在任何点重复,则这些值将被覆盖。看到 $A1、$A2 等的值是唯一的。

于 2012-12-14T06:05:53.760 回答