Skip to content

Instantly share code, notes, and snippets.

@dnikonov
Last active November 8, 2015 12:07
Show Gist options
  • Save dnikonov/a895f545d6eee37bb76e to your computer and use it in GitHub Desktop.
Save dnikonov/a895f545d6eee37bb76e to your computer and use it in GitHub Desktop.
BITRIX: form bootstrap
// result_modifier.php
$search = array();
$search["text"] = "/class=\"inputtext\"/";
$search["email"] = "/class=\"inputtext\"/";
$search["url"] = "/class=\"inputtext\"/";
$search["date"] = "/\<input /";
$search["textarea"] = "/class=\"inputtextarea\"/";
$search["dropdown"] = "/\<select /";
$search["radio"] = "/\<\/label\>\<label for=\"(\d+)\"\>/";
$replace = array();
$replace["text"] = "class=\"form-control\"";
$replace["email"] = "class=\"form-control\"";
$replace["url"] = "class=\"form-control\"";
$replace["date"] = "<input class=\"form-control\"";
$replace["textarea"] = "class=\"form-control\"";
$replace["dropdown"] = "<select class=\"form-control\"";
$replace["radio"] = "";
foreach ($arResult["QUESTIONS"] as $key => $value) {
if (array_key_exists($value["STRUCTURE"][0]["FIELD_TYPE"], $search)) {
$arResult["QUESTIONS"][$key]["HTML_CODE"] = preg_replace($search[$value["STRUCTURE"][0]["FIELD_TYPE"]], $replace[$value["STRUCTURE"][0]["FIELD_TYPE"]].($value["STRUCTURE"][0]["FIELD_TYPE"] != 'radio' ? " placeholder=\"".$arResult["QUESTIONS"][$key]["CAPTION"]."\"" : ""), $arResult["QUESTIONS"][$key]["HTML_CODE"]);
if ($value["STRUCTURE"][0]["FIELD_TYPE"] == "date") {
$arResult["QUESTIONS"][$key]["HTML_CODE"] = str_replace(" (DD.MM.YYYY)", "", $arResult["QUESTIONS"][$key]["HTML_CODE"]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment