commit d338275c1a7d94328ef2cd82e9d57cb03d5cc8af Author: Erik Stielstra Date: Sat Mar 29 15:57:37 2014 +0100 #10, Changed tableselect to table. diff --git a/developer/topics/forms_api_reference.html b/developer/topics/forms_api_reference.html index 9891549..026da59 100644 --- a/developer/topics/forms_api_reference.html +++ b/developer/topics/forms_api_reference.html @@ -85,7 +85,7 @@ For more extensive information about the Form API, see the range search select - tableselect + table text_format textarea textfield @@ -116,7 +116,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -146,7 +146,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -176,7 +176,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -207,7 +207,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -238,7 +238,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -269,7 +269,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -299,7 +299,7 @@ For more extensive information about the Form API, see the - X - - - + - - - X @@ -329,7 +329,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -359,7 +359,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -389,7 +389,7 @@ For more extensive information about the Form API, see the - - - - - + - X X - @@ -419,7 +419,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -449,7 +449,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -479,7 +479,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -509,7 +509,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -539,7 +539,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -569,7 +569,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -599,7 +599,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -629,7 +629,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -659,7 +659,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -689,7 +689,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -719,7 +719,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -749,7 +749,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -779,7 +779,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -809,7 +809,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -839,7 +839,7 @@ For more extensive information about the Form API, see the X X X - - + - X X X @@ -869,7 +869,7 @@ For more extensive information about the Form API, see the X X X - - + - X X X @@ -899,7 +899,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -929,7 +929,7 @@ For more extensive information about the Form API, see the - - - - X + X - - - @@ -959,7 +959,7 @@ For more extensive information about the Form API, see the - - X - - + - - - - @@ -989,7 +989,7 @@ For more extensive information about the Form API, see the - - X - - + - - - - @@ -1019,7 +1019,7 @@ For more extensive information about the Form API, see the - X X - - + - - X X @@ -1049,7 +1049,7 @@ For more extensive information about the Form API, see the - X X - - + - - X X @@ -1079,7 +1079,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -1109,7 +1109,7 @@ For more extensive information about the Form API, see the - - - - X + X - - - @@ -1139,7 +1139,7 @@ For more extensive information about the Form API, see the range search select - tableselect + table text_format textarea textfield @@ -1170,7 +1170,7 @@ For more extensive information about the Form API, see the - - - - X + X - - - @@ -1200,7 +1200,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -1230,7 +1230,7 @@ For more extensive information about the Form API, see the X - - - - + - - - - @@ -1260,7 +1260,7 @@ For more extensive information about the Form API, see the - X - - - + - - - X @@ -1290,7 +1290,7 @@ For more extensive information about the Form API, see the X - - - - + - - - - @@ -1320,7 +1320,7 @@ For more extensive information about the Form API, see the - - X - X + X - - - @@ -1350,7 +1350,7 @@ For more extensive information about the Form API, see the - - X - X + X - - - @@ -1380,7 +1380,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1410,7 +1410,7 @@ For more extensive information about the Form API, see the - X - - - + - - X X @@ -1441,7 +1441,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1471,7 +1471,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1501,7 +1501,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1531,7 +1531,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1561,7 +1561,7 @@ For more extensive information about the Form API, see the X X X - - + - X X X @@ -1591,7 +1591,7 @@ For more extensive information about the Form API, see the - - - - - + - X X - @@ -1599,6 +1599,36 @@ For more extensive information about the Form API, see the - #resizable + #responsive + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + X + - + - + - + - + - +#responsive + #return_value X - @@ -1621,7 +1651,7 @@ For more extensive information about the Form API, see the - - - - - + - - - - @@ -1651,7 +1681,7 @@ For more extensive information about the Form API, see the - - - - - + - X X - @@ -1681,7 +1711,7 @@ For more extensive information about the Form API, see the - X X - - + - - - X @@ -1711,7 +1741,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1741,7 +1771,7 @@ For more extensive information about the Form API, see the X - - - - + - - - - @@ -1749,6 +1779,36 @@ For more extensive information about the Form API, see the - #step + #sticky + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + X + - + - + - + - + - +#sticky + #suffix X X @@ -1771,7 +1831,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1779,6 +1839,66 @@ For more extensive information about the Form API, see the X #suffix + #tabledrag + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + X + - + - + - + - + - +#tabledrag + + #tableselect + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + X + - + - + - + - + - +#tableselect + #theme X X @@ -1801,7 +1921,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1831,7 +1951,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1861,7 +1981,7 @@ For more extensive information about the Form API, see the X X X - - + - X X X @@ -1891,7 +2011,7 @@ For more extensive information about the Form API, see the X X X - - + - X X X @@ -1921,7 +2041,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1951,7 +2071,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -1982,7 +2102,7 @@ For more extensive information about the Form API, see the X X X - X + X X X X @@ -3543,36 +3663,50 @@ of various settings for a select element, including behavior if #required is TRU $form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?> -

tableselect

+

table

+ +

Description:

+ Format a table. Can also be used for tables with selectable table rows (e.g checkboxes), draggable table rows and sortable header fields. + -

Description: -A table created with a far left column of radios or checkboxes. Build the table headings and -columns with the #headers property, and the rows with the #options property. See -Adding checkboxes to a table -for a full explanation.

Other settings:

-

Properties: #access, #after_build, #ajax, #attributes, #default_value, -#element_validate, #empty, -#header, #js_select, #multiple, #options, -#parents, #post_render, -#prefix, #pre_render, #process, #states, -#suffix, #theme, #theme_wrappers, -#tree, #type, -#weight

+

Properties: + #access, #after_build, #ajax, + #array_parents, #attached, + #attributes, #default_value, + #element_validate, #empty, + #header, #js_select (default for checkboxes: TRUE), + #multiple (default: TRUE), #options, + #parents, #post_render, + #prefix, #pre_render, #process, + #responsive (default: TRUE), #states, #sticky + #suffix, #tabledrag, + #tableselect, #theme, + #theme_wrappers, #tree, + #type, #value_callback, + #weight

-

Usage example (node.admin.inc):

+

Usage examples:

-
<?php
 
// Build the sortable table header.
 
$header = array(
   
'title' => array('data' => t('Title'), 'field' => 'n.title'),
   
'type' => array('data' => t('Type'), 'field' => 'n.type'),
   
'author' => t('Author'),
   
'status' => array('data' => t('Status'), 'field' => 'n.status'),
   
'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc')
  );
...
 
//Get the node data.
 
$nids = $query
   
->fields('n',array('nid'))
    ->
limit(50)
    ->
orderByHeader($header)
    ->
execute()
    ->
fetchCol();
 
$nodes = node_load_multiple($nids);
...
 
//Build the rows.
 
$options = array();
  foreach (
$nodes as $node) {
...
   
$options[$node->nid] = array(
     
'title' => array(
       
'data' => array(
         
'#type' => 'link',
         
'#title' => $node->title,
         
'#href' => 'node/' . $node->nid,
         
'#options' => $l_options,
         
'#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
        ),
      ),
     
'type' => check_plain(node_type_get_name($node)),
     
'author' => theme('username', array('account' => $node)),
     
'status' => $node->status ? t('published') : t('not published'),
     
'changed' => format_date($node->changed, 'short'),
    );
  
//For simplicity, this example omits the code to set the operations column.
...
 
//Build the tableselect.
 
$form['nodes'] = array(
     
'#type' => 'tableselect',
     
'#header' => $header,
     
'#options' => $options,
     
'#empty' => t('No content available.'),
    );
?>
+
<?php
 
/**
   * Basic table
   */
 
$header = array('first', 'second');
 
$rows = array(
    array(
'primera', 'secundo'),
    array(
'eerste', 'tweede'),
    array(
'1', '2'),
  );
 
$form['table'] = array(
   
'#type' => 'table',
   
'#header' => $header,
   
'#rows' => $rows,
   
'#empty' => $this->t('No info available.'),
  );
 
/**
   * Table with dragable rows.
   *
   * @see \Drupal\Core\Config\Entity\DraggableListBuilder::buildForm()
   */
 
$header = array('Number', 'Character');
 
$rows = array(
   
1 => array(
     
'data' => array('1', 'A'),
     
'class' => array('draggable'),
    ),
   
2 => array(
     
'data' => array('2', 'B'),
     
'class' => array('draggable'),
    ),
   
3 => array(
     
'data' => array('3', 'C'),
     
'class' => array('draggable'),
    ),
  );
 
$form['tabledrag'] = array(
   
'#type' => 'table',
   
'#header' => $header,
   
'#empty' => t('There is no label yet.'),
   
'#rows' => $rows,
   
'#tabledrag' => array(
      array(
       
'action' => 'order',
       
'relationship' => 'sibling',
       
'group' => 'weight',
      ),
    ),
   
'#attributes' => array(
     
'id' => 'tqbledrag-table',
    ),
  );
 
/**
   * Table with selectable rows.
   */
 
$users = array(
    array(
'uid' => 1, 'first_name' => 'Indy', 'last_name' => 'Jones'),
    array(
'uid' => 2, 'first_name' => 'Darth', 'last_name' => 'Vader'),
    array(
'uid' => 3, 'first_name' => 'Super', 'last_name' => 'Man'),
  );
 
$header = array(
   
'first_name' => t('First Name'),
   
'last_name' => t('Last Name'),
  );
 
$form['tableselect'] = array(
   
'#type' => 'table',
   
'#tableselect' => TRUE,
   
'#header' => $header,
   
'#empty' => t('No users found'),
  );
  foreach (
$users as $user) {
   
$form['tableselect'][$user['uid']] = array(
     
'first_name' => array('#markup' => check_plain($user['first_name'])),
     
'last_name' => array('#markup' => check_plain($user['last_name'])),
    );
  }
?>

text_format

@@ -3801,7 +3935,7 @@ be called after the form or element is built.

#ajax

Used by: button, checkbox, checkboxes, image button, password, -radio, radios, select, submit, tableselect, textarea, text_format, +radio, radios, select, submit, table, textarea, text_format, textfield

An array of elements whose values control the behavior of the @@ -4117,7 +4251,7 @@ $form['#attached']['js'][] = array(
  'data' => array('mymodule' =

#attributes

Used by: actions, button, checkbox, checkboxes, container, date, details, fieldset, file, form, image_button, password, -radio, radios, select, submit, tableselect, textarea, text_format, +radio, radios, select, submit, table, textarea, text_format, textfield, weight

Description: Additional HTML attributes, such as @@ -4298,7 +4432,7 @@ takes the form of "edit-ARRAY_KEY".

Used by: checkbox, checkboxes, -date, hidden, radio, radios, select, tableselect, textarea, +date, hidden, radio, radios, select, table, textarea, text_format, textfield, token, weight

Description: The value of the form element that @@ -4420,7 +4554,7 @@ over it, so in that case don't follow this usage example exactly.

#empty

-

Used by: tableselect

+

Used by: table

Description: Text to display if the #options property is empty.

@@ -4570,7 +4704,7 @@ $form['email'#header -

Used by: tableselect

+

Used by: table

Description: Column headers.

@@ -4595,7 +4729,7 @@ element.

#js_select

-

Used by: tableselect

+

Used by: table

Description: Whether to include a select all checkbox.

@@ -4698,7 +4832,7 @@ $form
['#method'#multiple -

Used by: select, tableselect

+

Used by: select, table

Description: Indicates whether the user may select more than one item.

@@ -4731,13 +4865,13 @@ more than one item.

#options

-

Used by: checkboxes, radios, select, tableselect

+

Used by: checkboxes, radios, select, table

Description: Selectable options for a form element that allows multiple choices.

Values: An array in the form of array(t('Display value 1'), t('Display value 2')) or array('return_value1' => t('Display Value 1'), 'return_value2' => t('Display Value 2')) if specific return values are required. If returned values are identical to displayed values, you can use drupal_map_assoc() as in the example below. -The #options property needs special handling for checkboxes, and works completely differently for tableselect. See the respective element descriptions for details.

+The #options property needs special handling for checkboxes, and works completely differently for table. See the respective element descriptions for details.

Usage example (form_example_states.inc):

@@ -5218,7 +5352,7 @@ element.

Values: button, checkbox, checkboxes, date, details, fieldset, file, form, hidden, image_button, item, machine_name, markup, password, password_confirm, radio, -radios, select, submit, tableselect, textarea, textfield, token, value, vertical_tabs, weight

+radios, select, submit, table, textarea, textfield, token, value, vertical_tabs, weight

Usage example (locale.module):