This is my code:
function theme_freeway_dashboard_details($form) {
$pidobtained = $_GET['project_id'] ;
$rows = array();
foreach (element_children($form) as $key) {
$row = array();
$row[] = array('data' => drupal_render($form[$key]['FileID']));
$row[] = array('data' => drupal_render($form[$key]['Filename']));
$row[] = array('data' => drupal_render($form[$key]['SourceLanguageID']));
$row[] = array('data' => drupal_render($form[$key]['TargetLanguageID']));
$row[] = array('data' => l(drupal_render($form[$key]['StatusID']),'user/1/freewayRetrieve',array('query' => array('fileId'=> $row[0],'projectID'=> $pidobtained))));
$row[] = array('data' => drupal_render($form[$key]['StatusDescription']));
$rows[] = $row;
}
$header = array();
$header[] = t('File ID');
$header[] = t('File Name');
$header[] = t('Source Language');
$header[] = t('Target Language');
$header[] = t('Status ID');
$header[] = t('Status Description');
//$output = theme('table', $header, $rows,array('size'=>10, 'class' => 'table_class'));
$output = theme('table', $header, $rows);
$output .= drupal_render($form);
return $output;
}
I am trying to pass paremeter on click on the link, the parameter being FileID. The URL being generated as a result of the above code is
'http://localhost/drupalTheme/user/1/freewayRetrieve?fileId[data]=157960&projectID=437286' .
Now when i try to get the values from this URL from the subsequesnt function using
<?php
$fileIdbtained = $_GET['fileId[data]'] ;
$pidobtained = $_GET['projectID'] ;
?>
I am getting the value for projectID but not for fileID. Is this the correct way to go about accessing the parameters?
Would like to have your views.
Thanks
A
To be clear: In your foreach loop,
$form[$key]['FileID']is a FAPI element.In other words: In every iteration of the loop, the variable
$form[$key]['FileID'](as well as$form[$key]['Filename']and the others) is a PHP array which has a specific structure.This “specific structure” is one that is expected by drupal_render() so that it knows how to “render” the element (that is, generate a string of HTML).
Now, for the case where you want to get the actual semantic value (i.e. 157960) of
$form[$key]['FileID']without the HTML, first you obviously have to stop passing it through drupal_render().Then, since
$form[$key]['FileID']is an array (which happens to hold the structure of a FAPI element, as I mentioned previously) you need to access whichever of its elements holds the actual data you’re after. And according to your latest update, that element would be the one with a key of ‘#value’.So, what you want to use is
$form[$key]['FileID']['#value']. That is, the line of code that prepares that row, should be: