123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- /**
- * taken from http://www.akchauhan.com/create-drupal-form-using-theme_table-like-module-list-form/
- * following as function theme_featured_product_form($form)
- *
- * to be run as a regular function, within a module's theme function implementation
- */
- function tripal_helper_form_themeform($form, $field_keys){
- $rows = array();
- foreach (element_children($form) as $key) {
- $row = array();
- if (isset($form[$key]['name'])) {
-
- $status = drupal_render($form['row_checkboxes'][$key]);
- $row[] = array(’data’ => $status, ‘class’ => ‘checkbox’);
-
- $bool_first = TRUE;
- foreach ($field_keys as $field_key => $value) {
- if($bool_first){
- $row[] = ‘‘. drupal_render($form[$key][$value]) .’‘;//for "bold style"
- $bool_first = FALSE;
- }
- else{
- $row[] = array(’data’ => drupal_render($form[$key][$value]),);
- }
- }
-
- $rows[] = $row;
- }
- }
- // Individual table headers.
- $header = array();
- $header[] = array(’data’ => t(’Select’), ‘class’ => ‘checkbox’);
-
- foreach ($field_keys as $key => $value) {
- $header[] = t("'$value'");
- }
-
- $output = theme(’table’, $header, $rows);
- $output .= drupal_render($form);
- dpm($output, 'formoutput');
- return $output;
- }
- function tripal_helper_form_createformdata($form, $query_results, $data_array){
- dpm($form, 'createform');
- dpm($query_results, 'createqeuryresults');
- dpm($data_array, 'createarray');
-
- // $status = array();
- $options = array();
-
- foreach ($query_results as $qr_key => $qr_value) {
- $options[$qr_key] = '';
-
- foreach ($data_array as $da_key => $da_value) {
- dpm($qr_value->$da_value, '$da_value');
- $form[$qr_key][$da_value] = array('#value' => $qr_value->$da_value);
-
- }
- // $status[] = '-1';
- }
-
- $form['row_checkboxes'] = array(
- '#type' => 'checkboxes',
- '#options' => $options,
- // '#default_value' => $status,
- );
-
- // $form['submit'] = array(
- // '#type' => 'submit',
- // '#value' => t('Remove'),
- // );
- //
- // $form['cancel'] = array(
- // '#type' => 'markup',
- // '#value' => l(t('Cancel'), 'dashboard'),
- // );
-
-
-
- return $form;
- }
|