当前位置: 首页>>代码示例>>PHP>>正文


PHP TextField::setAsNumeric方法代码示例

本文整理汇总了PHP中TextField::setAsNumeric方法的典型用法代码示例。如果您正苦于以下问题:PHP TextField::setAsNumeric方法的具体用法?PHP TextField::setAsNumeric怎么用?PHP TextField::setAsNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextField的用法示例。


在下文中一共展示了TextField::setAsNumeric方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getForm

 /**
  * Returns the form that this controller uses to manipulate the data stored
  * in its model. As stated earlier the form is either automatically generated
  * or it is loaded from an existing file which is located in the same
  * directory as the model and bears the model's name.
  *
  * @return Form
  */
 protected function getForm()
 {
     // Load a local form if it exists.
     if ($this->redirected) {
         $formName = $this->redirectedPackageName . Application::camelize($this->mainRedirectedPackage) . "Form";
         $formPath = $this->redirectPath . "/" . str_replace(".", "/", $this->mainRedirectedPackage) . "/" . $formName . ".php";
     } else {
         $formName = Application::camelize($this->model->package) . "Form";
         $formPath = $this->localPath . "/" . $formName . ".php";
     }
     if (is_file($formPath)) {
         include_once $formPath;
         $form = new $formName();
     } else {
         if (is_file($this->localPath . "/" . $this->name . "Form.php")) {
             include_once $this->localPath . "/" . $this->name . "Form.php";
             $formclass = $this->name . "Form";
             $form = new $formclass();
             $form->setModel($this->model);
         } else {
             // Generate a form automatically
             $fieldNames = array();
             $fields = $this->model->getFields();
             $form = new Form();
             $form->setModel($this->model);
             $names = array_keys($fields);
             for ($i = 0; $i < count($fields); $i++) {
                 $field = $fields[$names[$i]];
                 if ($field['key'] == 'primary') {
                     continue;
                 }
                 if ($fieldNames[$i]["renderer"] == "") {
                     if ($field["reference"] == "") {
                         switch ($field["type"]) {
                             case "boolean":
                                 $element = new Checkbox($field["label"], $field["name"], $field["description"], 1);
                                 break;
                             case "enum":
                                 $element = new SelectionList($field["label"], $field["name"]);
                                 foreach ($field["options"] as $value => $option) {
                                     $element->addOption($option, $value . "");
                                 }
                                 break;
                             case "date":
                             case "datetime":
                                 $element = new DateField($field["label"], $field["name"]);
                                 break;
                             case "integer":
                             case "double":
                                 $element = new TextField($field["label"], $field["name"], $field["description"]);
                                 $element->setAsNumeric();
                                 break;
                             case "textarea":
                                 $element = new TextArea($field["label"], $field["name"], $field["description"]);
                                 break;
                             default:
                                 $element = new TextField($field["label"], $field["name"], $field["description"]);
                                 break;
                         }
                     } else {
                         $element = new ModelField($field["reference"], $field["referenceValue"]);
                     }
                     foreach ($field["validators"] as $validator) {
                         switch ($validator["type"]) {
                             case "required":
                                 $element->setRequired(true);
                                 break;
                             case "unique":
                                 $element->setUnique(true);
                                 break;
                             case "regexp":
                                 $element->setRegexp((string) $validator["parameter"]);
                                 break;
                         }
                     }
                 } else {
                     $renderer = (string) $fieldNames[$i]["renderer"];
                     $element = new $renderer();
                 }
                 $form->add($element);
             }
             $form->addAttribute("style", "width:50%");
             $form->useAjax(true, false);
         }
     }
     return $form;
 }
开发者ID:rocksyne,项目名称:wyf,代码行数:95,代码来源:ModelController.php

示例2: createDefaultForm

 private function createDefaultForm()
 {
     // Generate a form automatically
     $fieldNames = array();
     $fields = $this->model->getFields();
     $form = new Form();
     $names = array_keys($fields);
     for ($i = 0; $i < count($fields); $i++) {
         $field = $fields[$names[$i]];
         if ($field['key'] == 'primary') {
             continue;
         }
         if ($fieldNames[$i]["renderer"] == "") {
             if ($field["reference"] == "") {
                 switch ($field["type"]) {
                     case "boolean":
                         $element = new Checkbox($field["label"], $field["name"], $field["description"], 1);
                         break;
                     case "enum":
                         $element = new SelectionList($field["label"], $field["name"]);
                         foreach ($field["options"] as $value => $option) {
                             $element->addOption($option, $value . "");
                         }
                         break;
                     case "date":
                     case "datetime":
                         $element = new DateField($field["label"], $field["name"]);
                         break;
                     case "integer":
                     case "double":
                         $element = new TextField($field["label"], $field["name"], $field["description"]);
                         $element->setAsNumeric();
                         break;
                     case "textarea":
                         $element = new TextArea($field["label"], $field["name"], $field["description"]);
                         break;
                     default:
                         $element = new TextField($field["label"], $field["name"], $field["description"]);
                         break;
                 }
             } else {
                 $element = new ModelField($field["reference"], $field["referenceValue"]);
             }
             foreach ($field["validators"] as $validator) {
                 switch ($validator["type"]) {
                     case "required":
                         $element->setRequired(true);
                         break;
                     case "unique":
                         $element->setUnique(true);
                         break;
                     case "regexp":
                         $element->setRegexp((string) $validator["parameter"]);
                         break;
                 }
             }
         } else {
             $renderer = (string) $fieldNames[$i]["renderer"];
             $element = new $renderer();
         }
         $form->add($element);
     }
     $form->addAttribute("style", "width:50%");
     $form->useAjax(true, false);
     return $form;
 }
开发者ID:9naQuame,项目名称:wyf,代码行数:66,代码来源:ModelController.php


注:本文中的TextField::setAsNumeric方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。