Anyone got a better way to code a wml / xhtml form function to enable both wml and xhtml in 1 page dynamically?
Heres my attempt:
usage:
or can anyone improve my code?
Heres my attempt:
PHP Code:
function buildform($wml,$action,$method,$fields,$submit,$postfields){
if($wml){
$fields = preg_replace("/>(.*?)\</textarea>/is"," value=\"$1\"/>",$fields);
$fields = str_replace("textarea","input",$fields);
$fields = str_replace("selected=\"selected\"","",$fields);
$form = $fields;
$form .= "<anchor>$submit<go href=\"$action\" method=\"$method\">";
$form .= $postfields;
$form .= "</go></anchor>";
}else{
$form = "<form action=\"$action\" method=\"$method\">";
$form .= $fields;
$form .= "<input type=\"submit\" value=\"$submit\"/>";
$form .= "</form>";
}
}
PHP Code:
echo buildform(TRUE,"something.php?else=yes","POST","<input name=\"test\" value=\"yes\"/>","Go","<postfield name=\"test\" value=\"$(test)\"/>");
Comment