You are here

README.txt in Matrix field 6.2

Same filename and directory in other branches
  1. 5 README.txt
  2. 6 README.txt
*************
** README: **
*************

DESCRIPTION:
-----------
This module provides a field type for cck with table view of form elements.
It is also possible to create use the element exposed by this module in the FAPI


REQUIREMENTS:
-------------
The matrix.module requires the content.module to be installed.


INSTALLATION:
-------------

1. Place the entire matrix directory into your Drupal modules/
   directory.


2. Enable the matrix module by navigating to:

     administer > site configuration > modules

   Enabling the matrix module will create the necessary database tables for you.


USING THE MATRIX MODULE (CCK):
------------------------------
After enableing the module, you can create a new field. Choose the Matrix field. On the configuration page,
there is an interface for adding rows and columns.  A live preview of your field will also be generated.

USING THE MATRIX MODULE (Form element):
------------------------------

/**
 * Implementation of hook_menu()
 */
function matrix_menu() {
  $items['matrix/example'] = array(
    'title' => 'Example use of matrix as a form element',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('matrix_example'),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Form Definition
 */
function matrix_example() {
  $form['matrixfield'] = array(
    '#type' => 'matrix',
    '#mode' => 'cols',
    '#title' => 'Example matrix element',
    '#description' => 'This is how you use it!',
    '#cols_elements' => array(
      array(
        '#type' => 'textfield',
        '#title' => 'Textbox 1',
        '#default_value' => 'One',
        '#required' => TRUE,
      ),
      array(
        '#type' => 'title',
        '#title' => 'Title 1',
      ),
      array(
        '#type' => 'select',
        '#title' => 'Select 1',
        '#options' => array('one' => 'One', 'two' => 'Two', 'three' => 'Three'),
        '#default_value' => 'two',
      ),
      array(
        '#type' => 'checkbox',
        '#title' => 'Checkbox 1',
        '#default_value' => TRUE,
      ),
      array(
        '#type' => 'radios',
        '#title' => 'Radios 1',
        '#options' => array('one' => 'One', 'two' => 'Two', 'three' => 'Three'),
        '#default_value' => 'two',
      ),
    ),
    '#rows_elements' => array(
      array(
        '#title' => 'Row 1'
      ),
      array(
        '#title' => 'Row 2'
      ),
      array(
        '#title' => 'Row 3'
      ),      
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit')
  );
  return $form;
}

/**
 * Implementation of hook_submit()
 */
function matrix_example_submit($form_id, $form_state) {
  print_r($form_state['values']['matrixfield']);
  die();
}


THEMEING:
---------
It is possible to alter the display of a CCK matrix field using the theme layer.
To do this you first need to copy two files to your theme directory:
* sites/all/modules/cck/theme/content-field.tpl.php file to your theme directory
* sites/all/modules/matrix/content-field-field_fieldname.tpl.php
Rename the second .tpl.php file, replacing "fieldname" with the name of your field
Rebuild your sites theme registry (admin >> performance >> clear cache)
Modify this file to do the theme changes you desire.

TODO:
-----
 * Allow users/administrators to add cols and rows dynamically
 * Add the facility to use any cck field in the matrix
 

Author:
-------
Original Author:
Matthias Hutterer
mh86@drupal.org
m_hutterer@hotmail.com

Current Maintainer:
Aaron Fulton
aaron@webtolife.org

File

README.txt
View source
  1. *************
  2. ** README: **
  3. *************
  4. DESCRIPTION:
  5. -----------
  6. This module provides a field type for cck with table view of form elements.
  7. It is also possible to create use the element exposed by this module in the FAPI
  8. REQUIREMENTS:
  9. -------------
  10. The matrix.module requires the content.module to be installed.
  11. INSTALLATION:
  12. -------------
  13. 1. Place the entire matrix directory into your Drupal modules/
  14. directory.
  15. 2. Enable the matrix module by navigating to:
  16. administer > site configuration > modules
  17. Enabling the matrix module will create the necessary database tables for you.
  18. USING THE MATRIX MODULE (CCK):
  19. ------------------------------
  20. After enableing the module, you can create a new field. Choose the Matrix field. On the configuration page,
  21. there is an interface for adding rows and columns. A live preview of your field will also be generated.
  22. USING THE MATRIX MODULE (Form element):
  23. ------------------------------
  24. /**
  25. * Implementation of hook_menu()
  26. */
  27. function matrix_menu() {
  28. $items['matrix/example'] = array(
  29. 'title' => 'Example use of matrix as a form element',
  30. 'page callback' => 'drupal_get_form',
  31. 'page arguments' => array('matrix_example'),
  32. 'access arguments' => array('access content'),
  33. 'type' => MENU_CALLBACK,
  34. );
  35. return $items;
  36. }
  37. /**
  38. * Form Definition
  39. */
  40. function matrix_example() {
  41. $form['matrixfield'] = array(
  42. '#type' => 'matrix',
  43. '#mode' => 'cols',
  44. '#title' => 'Example matrix element',
  45. '#description' => 'This is how you use it!',
  46. '#cols_elements' => array(
  47. array(
  48. '#type' => 'textfield',
  49. '#title' => 'Textbox 1',
  50. '#default_value' => 'One',
  51. '#required' => TRUE,
  52. ),
  53. array(
  54. '#type' => 'title',
  55. '#title' => 'Title 1',
  56. ),
  57. array(
  58. '#type' => 'select',
  59. '#title' => 'Select 1',
  60. '#options' => array('one' => 'One', 'two' => 'Two', 'three' => 'Three'),
  61. '#default_value' => 'two',
  62. ),
  63. array(
  64. '#type' => 'checkbox',
  65. '#title' => 'Checkbox 1',
  66. '#default_value' => TRUE,
  67. ),
  68. array(
  69. '#type' => 'radios',
  70. '#title' => 'Radios 1',
  71. '#options' => array('one' => 'One', 'two' => 'Two', 'three' => 'Three'),
  72. '#default_value' => 'two',
  73. ),
  74. ),
  75. '#rows_elements' => array(
  76. array(
  77. '#title' => 'Row 1'
  78. ),
  79. array(
  80. '#title' => 'Row 2'
  81. ),
  82. array(
  83. '#title' => 'Row 3'
  84. ),
  85. ),
  86. );
  87. $form['submit'] = array(
  88. '#type' => 'submit',
  89. '#value' => t('Submit')
  90. );
  91. return $form;
  92. }
  93. /**
  94. * Implementation of hook_submit()
  95. */
  96. function matrix_example_submit($form_id, $form_state) {
  97. print_r($form_state['values']['matrixfield']);
  98. die();
  99. }
  100. THEMEING:
  101. ---------
  102. It is possible to alter the display of a CCK matrix field using the theme layer.
  103. To do this you first need to copy two files to your theme directory:
  104. * sites/all/modules/cck/theme/content-field.tpl.php file to your theme directory
  105. * sites/all/modules/matrix/content-field-field_fieldname.tpl.php
  106. Rename the second .tpl.php file, replacing "fieldname" with the name of your field
  107. Rebuild your sites theme registry (admin >> performance >> clear cache)
  108. Modify this file to do the theme changes you desire.
  109. TODO:
  110. -----
  111. * Allow users/administrators to add cols and rows dynamically
  112. * Add the facility to use any cck field in the matrix
  113. Author:
  114. -------
  115. Original Author:
  116. Matthias Hutterer
  117. mh86@drupal.org
  118. m_hutterer@hotmail.com
  119. Current Maintainer:
  120. Aaron Fulton
  121. aaron@webtolife.org