field_a_nr); $i ++)
{
$article = node_load($node->field_a_nr[$i]['nid']);
$node_field[$i]['value'] = $article->field_price[0]['value'];
}
?>
or for summand all articles to an end price
field_r_articleprice); $i ++)
{
if (is_numeric($node->field_r_articleprice[$i-1]['value']))
{
if (is_numeric($node->field_a_count[$i-1]['value']))
{
$node_field[$i-1]['value'] = $node->field_r_articleprice[$i-1]['value']*$node->field_a_count[$i-1]['value'];
}
}
}
?>
So the user doesn't have to calculate any more.
Steps:
1. Creation of Themes
The first theme was a basic try to use theming form, f.e. how can fields be displayed in a table
General '. drupal_render($form['field_client'])?>
Choose the Articles
Articel
Count
';
// The main Table; for each article a field for the article and on for the count
for($i=0; $i < $count; $i++)
{
if ($i % 2 == 1)
{
$var = 'even';
}
else
{
$var = 'odd';
}
$output .= '';
$output .= ''. drupal_render($form['group_bill']['field_a_nr'][$i]). ' ';
$output .= ''. drupal_render($form['group_bill']['field_a_count'][$i]) . ' ';
}
$output .= '
';
echo $output;
// the mailing exchanges, the text for the client etc.
echo drupal_render($form['group_aggregation']['field_bill_me']);
echo drupal_render($form['field_bill_text']);
echo drupal_render($form['form_token']);
echo drupal_render($form['form_id']);
echo drupal_render($form['options']);
echo drupal_render($form['preview'])
echo drupal_render($form['submit']);
?>
The second theme displays the form as Tabs with JSTabs in JSTools
';
$output .= ' General '. drupal_render($form['field_client']);
$output .= '';
$output .= '';
$output .= drupal_render($form['field_seller']);
$output .= '';
$output .= '';
$output .= drupal_render($form['field_pay_date']);
$output .= '';
// An extra variable for better integration into JSTABS
$content['general'] = $output;
// Print a table with fields for the Nodereference A_NR to an Artical and the count of this articles
// How many Articles?
$count = count(element_children($form['group_bill']['field_a_nr']));
// $Output as a tmp variable
// first the head of an table
$output = '
Choose the Articles
Articel
Count
';
// The main Table; for each article a field for the article and on for the count
for($i=0; $i < $count; $i++)
{
if ($i % 2 == 1)
{
$var = 'even';
}
else
{
$var = 'odd';
}
$output .= '';
$output .= ''. drupal_render($form['group_bill']['field_a_nr'][$i]). ' ';
$output .= ''. drupal_render($form['group_bill']['field_a_count'][$i]) . ' ';
}
$output .= '
';
$content['bill'] = $output;
$content['text'] = drupal_render($form['field_bill_text']);
// definition of the tabset and the tabpages
$formtab['tabblock1'] = array(
'#type' => 'tabset',
);
$formtab['tabblock1']['tab1'] = array(
'#type' => 'tabpage',
'#title' => t('General'),
'#content' => $content['general'],
'#weight' => -10,
);
$formtab['tabblock1']['tab2'] = array(
'#type' => 'tabpage',
'#title' => t('Bill'),
'#content' => $content['bill'],
'#weight' => -2 ,
);
$formtab['tabblock1']['tab3'] = array(
'#type' => 'tabpage',
'#title' => t('text'),
'#content' => $content['text'],
);
// render the tabs
echo tabs_render($formtab);
echo drupal_render($form['form_token']);
echo drupal_render($form['form_id']);
echo drupal_render($form['options']);
echo drupal_render($form['preview']);
echo drupal_render($form('submit']);
?>
The third theme displays the form like the standard way but with a css class .item. This class is used by jquery to hide, first each element, and than show the next form by clicking the next link or the key [page down]
First you have nothing
Than after 3 [Page downs]
3.bill-edit.tpl.php:
'. drupal_render($form['title']) .'';
echo ''. drupal_render($form['field_client']) .'';
echo ''. drupal_render($form['field_pay_date']) .'';
echo ''. drupal_render($form['field_seller']) .'';
echo ''. drupal_render($form['field_a_nr']) .'';
echo ''. drupal_render($form['field_a_count']) .'';
echo ''. drupal_render($form['field_bill_me']) .'';
echo ''. drupal_render($form['field_bill_text']) .'';
?>
3bill.js:
$('#node-form > div').prepend('Next Click [Page Down] to show the next element
and [Page Up] to hide the last elment');
// Shows the first hidden Item
$('#node-form > div > .item:first').show();
// Adds a function if the Link is clicked
$('#node-form > div > a#click').click( function() {
// Shows the first hidden element -> the next item
$('#node-form > div > .item:hidden:first').show()
});
// If you click Page Down the next Element get visible
$(document).keyup( function(event) {
if (event.keyCode == 34) {
$('#node-form > div > .item:hidden:first').show();
}
else if (event.keyCode == 33)
{
$('#node-form > div > .item:visible:last').hide();
}
});
});
2.problems
For submitting the form I had to have: