a problem in theme function

drudev - January 12, 2009 - 15:11

hi every body when i tried to theme my form in table and tried the fowlloing example
function supervisors_display(){
$r = db_rewrite_sql(db_query('SELECT nid, title, created FROM {node} LIMIT 20'));
while ($row = db_fetch_object($r)) {
$rows[] = $row;
}

foreach ($rows as $v) {
$nids[$v->nid] = '';
$form['title'][$v->nid] = array('#type' => 'markup', '#value' => check_plain($v->title));
$form['created'][$v->nid] = array('#type' => 'markup', '#value' => date("d/m/Y H:i", $v->created));
}
$form['nids'] = array('#type' => 'checkboxes', '#options' => $nids);
$form['submit'] = array('#type' => 'submit', '#value' => 'Update');

$form['header'] = array(
'#type' => 'value',
'#value' => array(
array('data' => 'nid'),
array('data' => t('Title')),
array('data' => t('Created')),
)
);

return $form;
}

function theme_supervisors_display($form) {

foreach (element_children($form['title']) as $key) {
$row = array();
$row['data'][0] = form_render($form['nids'][$key]);
$row['data'][1] = form_render($form['title'][$key]);
$row['data'][2] = form_render($form['created'][$key]);
$rows[] = $row;
}

$output = form_render(theme('table', $form['header']['#value'], $rows));
$output.= form_render($form); // Process any other fields and display them
return $output;
}

actually the data appear to me like this

first03/12/2008 16:44

whith out any theme
so please if any one can help me please .

form_render() doesn't exists for D6

francort - January 12, 2009 - 20:55

As far as i know, there is no form_render() function for Drupal 6 but for Drupal 4.7.
http://api.drupal.org is a good place to see what functions are available on drupal's api

thanks

drudev - January 13, 2009 - 11:53

thank you very much the function in d6 is drupal_render but there is another problem when i chang the function the folowing warning appears
warning: Invalid argument supplied for foreach() in C:\Program Files\EasyPHP 2.0b1\www\includes\common.inc on line 2720.
so if you have an idea about this
thank you agin.

.

francort - January 13, 2009 - 14:54

form_render() needs an array.
theme() , returns a string

So, if you do form_render( theme() ) , you're giving a string to a function that needs an array.

I think you don't need that form_render( theme() ) but just theme()

Perhaps you want to take a look to drupal_render_form() and Form generation

thanks

drudev - January 14, 2009 - 11:27

Thank you very much francort i tried abit differnet technique so i use tapir module and gave me avey good result
thank you again

good!

francort - January 14, 2009 - 16:11

It seems to be a useful module. Nevertheless, it is for Drupal 5 ¿have you changed your Drupal version because of this issue?

for drupal 5?

drudev - January 20, 2009 - 09:44

hi how r u ?
the module exisit for d6 and it's great

 
 

Drupal is a registered trademark of Dries Buytaert.