これが私のフォームです
function dreamcharts_step7_form(&$form, &$form_state) {
$dream = &$form_state['dream_obj'];
$form['weight'] = array(
'#type' => 'textfield',
'#title' => 'Weight',
);
$form['tall'] = array(
'#title' => 'How tall are you?',
'#type' => 'select',
'#required' => 1,
'#default_value' => $dream->tall,
'#value' => array(
'0' => '58',
'1' => '59',
'2' => '60',
'3' => '61',
'4' => '62',
'5' => '63',
'6' => '64',
'7' => '65',
'8' => '66',
'9' => '67',
'10' => '68',
'11' => '69',
'12' => '70',
'13' => '71',
'14' => '72',
'15' => '73',
'16' => '74',
'17' => '75',
'18' => '76',
),
'#options' => array(
'0' => '4\' 10"',
'1' => '4\' 11"',
'2' => '5\' 0"',
'3' => '5\' 1"',
'4' => '5\' 2"',
'5' => '5\' 3"',
'6' => '5\' 4"',
'7' => '5\' 5"',
'8' => '5\' 6"',
'9' => '5\' 7"',
'10' => '5\' 8"',
'11' => '5\' 9"',
'12' => '5\' 10"',
'13' => '5\' 11"',
'14' => '6\' 0"',
'15' => '6\' 1"',
'16' => '6\' 2"',
'17' => '6\' 3"',
'18' => '6\' 4"',
)
);
$form['tip'] = array(
'#type' => 'markup',
'#prefix' => '<div id="hint">',
'#suffix' => '</div>',
'#value' => 'The combination of your weight and height lets us know your Body Mass Index or BMI.',
);
$form_state['no buttons'] = TRUE;
}
ここでフォームの値を計算します
function dreamcharts_step7_form_submit(&$form, &$form_state) {
$tall = $form_state['values']['tall'];
$weight = $form_state['values']['weight'];
$form_state['dream_obj']->bmi = (($weight * 703) / ($tall * $height));
}
この行でサポートされていないオペランド型を取得しています
$form_state['dream_obj']->bmi = (($weight * 703) / ($tall * $height));