in bmi.module .

For starters, all strings in output should be enclosed in a t("") for translation.

That's not the case in lines 66 and 82.
'#title' => 'Units',

Should be
'#title' => t("Units"),

And in line 119, where it reads

    $output = "Your BMI value is <b>". $bmi ."</b>";
    $output .= "<br>". $bmi_text;

Should be

    $output = t("Your BMI value is");
    $output .= " <b>". $bmi ."</b><br>". $bmi_text;

And that's that for translation issues.

I guess that after the form button there should be some markup with style="clear:both"

You did it like this at line 102:
'#suffix' => '</div>',

i've done
'#suffix' => '</div><br style="clear:both">',

Next, if you input the data and hit enter while on the textfield, it goes awfully wrong, redirecting you to a non-related page and clearing out the input.

I've solved this by adding some js in line 58, so it reads like

    '#required' => TRUE,
    '#attributes' => array(
      'onkeypress' => ' var key;if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) return false; else return true; '
    ),
    '#prefix' => '<div style="float:left;">',

and at line 76

    '#required' => TRUE,
    '#attributes' => array(
      'onkeypress' => ' var key;if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) return false; else return true; '
    ),
    '#prefix' => '<div style="float:left;">',

It catches the enter key on textfield and blocks it, so the form don't get submitted.

And finally, added some js at line 93 to clear the message if 'Calculate' gets hit again.

    '#attributes' => array(
      'onmouseup' => ' document.getElementById("bmi_calculate_wrapper").firstChild.innerHTML = ""; '
    ),

Best wishes

Comments

HLopes’s picture

Status: Active » Closed (duplicate)

Duplicate