本文整理汇总了PHP中Forge::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Forge::__toString方法的具体用法?PHP Forge::__toString怎么用?PHP Forge::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forge
的用法示例。
在下文中一共展示了Forge::__toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Forge
function group_test()
{
$form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm"));
$group = $form->group("test_group")->label(t("Test Group"));
$group->input("title")->label(t("Title"));
$group->textarea("description")->label(t("Text Area"));
$group->submit("")->value(t("Submit"));
$rendered = $form->__toString();
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . "id=\"gTestGroupForm\">\n" . "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . " <fieldset>\n" . " <legend>Test Group</legend>\n" . " <ul>\n" . " <li>\n" . " <label for=\"title\" >Title</label>\n" . " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " . "class=\"textbox\" />\n" . " </li>\n" . " <li>\n" . " <label for=\"description\" >Text Area</label>\n" . " <textarea id=\"description\" name=\"description\" " . "class=\"textarea\" ></textarea>\n" . " </li>\n" . " <li>\n" . " <input type=\"submit\" value=\"Submit\" class=\"submit\" />\n" . " </li>\n" . " </ul>\n" . " </fieldset>\n" . "</form>\n";
$this->assert_same($expected, $rendered);
}
示例2: Forge
function form_script_test()
{
$form = new Forge("test/controller", "", "post", array("id" => "g-test-group-form"));
$group = $form->group("test_group")->label(t("Test Group"));
$group->input("title")->label(t("Title"));
$group->textarea("description")->label(t("Text Area"));
$form->script("")->url(url::file("test.js"))->text("alert('Test Javascript');");
$group->submit("")->value(t("Submit"));
$rendered = $form->__toString();
$csrf = access::csrf_token();
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . "id=\"g-test-group-form\">\n" . "<input type=\"hidden\" name=\"csrf\" value=\"{$csrf}\" />" . " <fieldset>\n" . " <legend>Test Group</legend>\n" . " <ul>\n" . " <li>\n" . " <label for=\"title\" >Title</label>\n" . " <input type=\"text\" name=\"title\" value=\"\" " . "class=\"textbox\" />\n" . " </li>\n" . " <li>\n" . " <label for=\"description\" >Text Area</label>\n" . " <textarea name=\"description\" rows=\"\" cols=\"\" " . "class=\"textarea\" ></textarea>\n" . " </li>\n" . " <li>\n" . " <input type=\"submit\" value=\"Submit\" class=\"submit\" />\n" . " </li>\n" . " </ul>\n" . " </fieldset>\n" . "<script type=\"text/javascript\" src=\"http://./test.js\"></script>\n\n" . "<script type=\"text/javascript\">\n" . "alert('Test Javascript');\n" . "</script>\n" . "</form>";
$this->assert_same($expected, $rendered);
}