Добавление нового настраиваемого поля / столбца для администратора контента - PullRequest
0 голосов
/ 26 января 2012

Мне удалось добавить элемент внизу таблицы. Хотя я не уверен, как вы ДОБАВЛЯЕТЕ колонку в теле стола?

function seven_form_alter(&$form, &$form_state, $form_id) {
        drupal_set_message("Form ID is : " . $form_id);

        //get node_admin_content
        //$nodeAdmin = drupal_get_form("node_admin_content");


          // Add a checkbox to registration form about agreeing to terms of use.
  $form['node_admin_content']['poland'] = array(
    '#type' => 'checkbox', 
    '#title' => t("I agree with the website's terms and conditions."), 
    '#required' => TRUE,
  );

}

1 Ответ

1 голос
/ 26 января 2012

Таблица построена на node_admin_nodes() и поставляется в хорошем массиве рендеринга, поэтому вы можете переопределить ее:

// Get the header array and add your new column header
$header = $form['admin']['nodes']['#header'];
$header['new_column'] = array('data' => 'New Col Header');
$form['admin']['nodes']['#header'] = $header;

// Get the table rows and add your new column to each.
// The function used to output the table depends on the user permissions
// so you need to check what type of object is being rendered.
if (isset($form['admin']['nodes']['#options'])) {
  $row_key = '#options';
}
else {
  $row_key = '#rows';
}

$rows = $form['admin']['nodes'][$row_key];

foreach ($rows as $nid => $row) {
  $form['admin']['nodes'][$row_key][$nid]['new_column'] = array('data' => 'Text');
}
...