本文整理匯總了PHP中FieldSet::setId方法的典型用法代碼示例。如果您正苦於以下問題:PHP FieldSet::setId方法的具體用法?PHP FieldSet::setId怎麽用?PHP FieldSet::setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FieldSet
的用法示例。
在下文中一共展示了FieldSet::setId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getForm
/**
* Returns a form to be used to filter the report. This method analyses the
* XML file and uses the fields specified in there to generate a very form
* which allows you to define filter for the form. The form generated also
* gives you options to sort and group the reports.
* @return Form
*/
public function getForm()
{
$this->initializeForm();
$filters = array();
$fieldInfos = array();
$queries = $this->xml->xpath("/rapi:report/rapi:query");
$tables = $this->xml->xpath("/rapi:report/rapi:table");
/// Filters and sorting.
foreach ($tables as $table) {
$numConcatFields = 0;
$fields = $table->xpath("/rapi:report/rapi:table[@name='{$table["name"]}']/rapi:fields/rapi:field");
$labels = $table->xpath("/rapi:report/rapi:table[@name='{$table["name"]}']/rapi:fields/rapi:field/@label");
$filters = new TableLayout(count($fields) + 1, 5);
$filters->add(Element::create("Label", "Field")->addCssClass("header-label"), 0, 0)->add(Element::create("Label", "Options")->addCssClass("header-label"), 0, 1)->add(Element::create("Label", "Exclude")->addCssClass("header-label"), 0, 4)->resetCssClasses()->addCssClass("filter-table")->setRenderer("default");
$sortingField = new SelectionList("Sorting Field", "{$table["name"]}_sorting_field");
$grouping1 = new SelectionList();
$i = 1;
foreach ($fields as $key => $field) {
if (isset($field["labelsField"])) {
continue;
}
if (count(explode(",", (string) $field)) == 1) {
$fieldInfo = Model::resolvePath((string) $field);
$model = Model::load($fieldInfo["model"]);
$fieldName = $fieldInfo["field"];
$fieldInfo = $model->getFields(array($fieldName));
$fieldInfo = $fieldInfo[0];
$fields[$key] = (string) $field;
$sortingField->addOption(str_replace("\\n", " ", $fieldInfo["label"]), $model->getDatabase() . "." . $fieldInfo["name"]);
$grouping1->addOption(str_replace("\\n", " ", $field["label"]), (string) $field);
if (array_search($model->getKeyField(), $this->referencedFields) === false || $fieldInfo["type"] == "double" || $fieldInfo["type"] == "date") {
switch ($fieldInfo["type"]) {
case "integer":
case "double":
$filters->add(Element::create("Label", str_replace("\\n", " ", (string) $field["label"])), $i, 0)->add(Element::create("SelectionList", "", "{$table["name"]}.{$fieldInfo["name"]}_option")->addOption("Equals", "EQUALS")->addOption("Greater Than", "GREATER")->addOption("Less Than", "LESS")->addOption("Between", "BETWEEN")->setValue("BETWEEN"), $i, 1)->add(Element::create("TextField", "", "{$table["name"]}.{$fieldInfo["name"]}_start_value")->setAsNumeric(), $i, 2)->add(Element::create("TextField", "", "{$table["name"]}.{$fieldInfo["name"]}_end_value")->setAsNumeric(), $i, 3);
//->add(Element::create("Checkbox","","{$table["name"]}.{$fieldInfo["name"]}_ignore","","1"),$i,4);
break;
case "date":
case "datetime":
$filters->add(Element::create("Label", str_replace("\\n", " ", (string) $field["label"])), $i, 0)->add(Element::create("SelectionList", "", "{$table["name"]}.{$fieldInfo["name"]}_option")->addOption("Before", "LESS")->addOption("After", "GREATER")->addOption("On", "EQUALS")->addOption("Between", "BETWEEN")->setValue("BETWEEN"), $i, 1)->add(Element::create("DateField", "", "{$table["name"]}.{$fieldInfo["name"]}_start_date")->setId("{$table["name"]}_{$fieldInfo["name"]}_start_date"), $i, 2)->add(Element::create("DateField", "", "{$table["name"]}.{$fieldInfo["name"]}_end_date")->setId("{$table["name"]}_{$fieldInfo["name"]}_end_date"), $i, 3);
//->add(Element::create("Checkbox","","{$table["name"]}.{$fieldInfo["name"]}_ignore","","1"),$i,4);
break;
case "enum":
$enum_list = new SelectionList("", "{$table["name"]}.{$fieldInfo["name"]}_value");
$enum_list->setMultiple(true);
foreach ($fieldInfo["options"] as $value => $label) {
$enum_list->addOption($label, $value);
}
if (!isset($field["value"])) {
$filters->add(Element::create("Label", str_replace("\\n", " ", (string) $field["label"])), $i, 0)->add(Element::create("SelectionList", "", "{$table["name"]}.{$fieldInfo["name"]}_option")->addOption("Is any of", "INCLUDE")->addOption("Is none of", "EXCLUDE")->setValue("INCLUDE"), $i, 1)->add($enum_list, $i, 2);
}
//->add(Element::create("Checkbox","","{$table["name"]}.{$fieldInfo["name"]}_ignore","","1"),$i,4);
break;
case "string":
case "text":
$filters->add(Element::create("Label", str_replace("\\n", " ", (string) $field["label"])), $i, 0)->add(Element::create("SelectionList", "", "{$table["name"]}.{$fieldInfo["name"]}_option")->addOption("Is exactly", "EXACTLY")->addOption("Contains", "CONTAINS")->setValue("CONTAINS"), $i, 1)->add(Element::create("TextField", "", "{$table["name"]}.{$fieldInfo["name"]}_value"), $i, 2);
//->add(Element::create("Checkbox","","{$table["name"]}.{$fieldInfo["name"]}_ignore","","1"),$i,4);
break;
}
if (isset($field["hide"])) {
$filters->add(Element::create("HiddenField", "{$table["name"]}.{$fieldInfo["name"]}_ignore", "1"), $i, 4);
} else {
$filters->add(Element::create("Checkbox", "", "{$table["name"]}.{$fieldInfo["name"]}_ignore", "", "1"), $i, 4);
}
} else {
$enum_list = new ModelSearchField();
$enum_list->setName("{$table["name"]}.{$fieldInfo["name"]}_value");
$enum_list->setModel($model, $fieldInfo["name"]);
$enum_list->addSearchField($fieldInfo["name"]);
$enum_list->boldFirst = false;
$filters->add(Element::create("Label", str_replace("\\n", " ", (string) $field["label"])), $i, 0)->add(Element::create("SelectionList", "", "{$table["name"]}.{$fieldInfo["name"]}_option")->addOption("Is any of", "IS_ANY_OF")->addOption("Is none of", "IS_NONE_OF")->setValue("IS_ANY_OF"), $i, 1)->add(Element::create("MultiFields")->setTemplate($enum_list), $i, 2)->add(Element::create("Checkbox", "", "{$table["name"]}.{$fieldInfo["name"]}_ignore", "", "1"), $i, 4);
}
} else {
$grouping1->addOption(str_replace("\\n", " ", $field["label"]), $field);
$filters->add(Element::create("Label", str_replace("\\n", " ", (string) $field["label"])), $i, 0)->add(Element::create("SelectionList", "", "{$table["name"]}_concat_{$numConcatFields}_option")->addOption("Is exactly", "EXACTLY")->addOption("Contains", "CONTAINS")->setValue("CONTAINS"), $i, 1)->add(Element::create("TextField", "", "{$table["name"]}_concat_{$numConcatFields}_value"), $i, 2)->add(Element::create("Checkbox", "", "{$table["name"]}_concat_{$numConcatFields}_ignore", "", "1"), $i, 4);
$numConcatFields++;
}
$i++;
}
$grouping1->setName("{$table["name"]}_grouping[]")->setLabel("Grouping Field 1");
$g1Paging = new Checkbox("Start on a new page", "grouping_1_newpage", "", "1");
$g1Logo = new Checkbox("Repeat Logos", "grouping_1_logo", "", "1");
$g1Summarize = new Checkbox("Summarize", "grouping_1_summary", "", "1");
$grouping2 = clone $grouping1;
$grouping2->setName("{$table["name"]}_grouping[]")->setLabel("Grouping Field 2");
$g2Paging = new Checkbox("Start on a new page", "grouping_2_newpage", "", "1");
$g2Logo = new Checkbox("Repeat Logos", "grouping_2_logo", "", "1");
$grouping3 = clone $grouping1;
$grouping3->setName("{$table["name"]}_grouping[]")->setLabel("Grouping Field 3");
$g3Paging = new Checkbox("Start on a new page", "grouping_3_newpage", "", "1");
$g3Logo = new Checkbox("Repeat Logos", "grouping_3_logo", "", "1");
$sortingField->setLabel("Sorting Field");
$sortingField->setName($table["name"] . "_sorting");
//.........這裏部分代碼省略.........