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


PHP SiteHelper::getRelation方法代码示例

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


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

示例1: addForm

 static function addForm($form, $captcha = false, Controller $controller = null)
 {
     $fields = $form->attributeLabels();
     $relationList = $form->getRelationFields();
     $relations = $form->relations();
     $fieldType = $form->fieldType();
     $requiredFields = $form->getRequiredAttributes();
     $placeholder = $form->attributePlaceholder();
     $saveFields = $form->getSafeAtributes();
     $cout = "";
     $classTable = get_class($form);
     foreach ($fields as $field => $key) {
         // Если идет добаление элемента но произошла ошибка то воспроизводит введеные значения
         $paramValue = !empty($_POST[$classTable][$field]) ? $_POST[$classTable][$field] : "";
         if (!empty($paramValue) && !$form->{$field}) {
             $form->{$field} = $paramValue;
         }
         // end
         // Обязаельное поле
         if (self::find_in_array($field, $requiredFields)) {
             $requiredAttr = "required";
         } else {
             $requiredAttr = "";
         }
         // Вытаскиваем тип поля
         $fieldTypeValue = !empty($fieldType[$field]) ? $fieldTypeValue = $fieldType[$field] : "";
         if (!in_array($field, $relationList) && (empty($fieldTypeValue) || empty($relations[$fieldTypeValue]))) {
             // Подсказка к полю
             if (!empty($placeholder[$field])) {
                 $fieldPlaceholder = $placeholder[$field];
             } else {
                 $fieldPlaceholder = "";
             }
             // нужно проверить если данное поле не указанно в списке SAVE то вывести не поля ввода а просто значение
             $input = "";
             if (CCModelHelper::find_in_array($field, $saveFields) || $field == "password2") {
                 if (!empty($fieldType[$field])) {
                     switch ($fieldType[$field]) {
                         case "url":
                             $input = CHtml::activeUrlField($form, $field, array("placeholder" => $fieldPlaceholder, $requiredAttr => "")) . "<br/><font class='smallGrey'>формат: http://www.sitename.ru</font>";
                             break;
                         case "email":
                             $input = CHtml::activeEmailField($form, $field, array("placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                             break;
                         case "date":
                             if ((int) $form->{$field} > 0) {
                                 $form->{$field} = date("Y-m-d", (int) $form->{$field});
                             }
                             $input = CHtml::activeDateField($form, $field, array("placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                             break;
                         case "password":
                             $input = CHtml::passwordField($classTable . "[" . $field . "]", '', array("placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                             break;
                         case "checkbox":
                             $input = CHtml::activeCheckBox($form, $field, array("placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                             break;
                         case "visual_textarea":
                             $input = $fieldPlaceholder . CHtml::activeTextArea($form, $field, array("cols" => 50, "rows" => 10, "class" => "tinymce", "placeholder" => $fieldPlaceholder));
                             break;
                         case "textarea":
                             $input = CHtml::activeTextArea($form, $field, array("cols" => 50, "rows" => 10, "class" => "mceNoEditor", "placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                             break;
                         case "image":
                             if ($form->{$field}) {
                                 $catalog = get_class($form);
                                 $input = '<img src="../' . ImageHelper::getImage($form->{$field}, 2, $form) . '" width="100" /><br/>';
                                 if (Yii::app()->controller->module->id == "console") {
                                     $input .= '<a href="' . SiteHelper::createUrl("/console/catalog/edit", array("id" => $form->id)) . "?catalog=" . $catalog . "&action=img_del&field=" . $field . '">[<?= Yii::t("user", "Удалить") ?>]</a><br/>';
                                 }
                                 $input .= CHtml::hiddenField($catalog . "[old_" . $field . "]", $form->{$field});
                             }
                             $input .= CHtml::activeFileField($form, $field, array($requiredAttr => ""));
                             break;
                         case "file":
                             if ($form->{$field}) {
                                 $catalog = get_class($form);
                                 $input = '<a href="../' . $form->{$field} . '" target="_blank">' . $form->{$field} . '</a><br/>';
                                 if (Yii::app()->controller->module->id == "console") {
                                     $input .= '<a href="' . SiteHelper::createUrl("/console/catalog/edit", array("id" => $form->id)) . "?catalog=" . $catalog . "&action=img_del&field=" . $field . '">[<?= Yii::t("user", "Удалить") ?>]</a><br/>';
                                 }
                                 $input .= CHtml::hiddenField($catalog . "[old_" . $field . "]", $form->{$field});
                             }
                             $input .= CHtml::activeFileField($form, $field, array($requiredAttr => ""));
                             break;
                         case "label":
                             $input = $form->{$field};
                             break;
                         default:
                             $input = CHtml::activeTextField($form, $field, array("placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                     }
                 } else {
                     $input = CHtml::activeTextField($form, $field, array("placeholder" => $fieldPlaceholder, $requiredAttr => ""));
                 }
             } else {
                 $input = $form->{$field};
             }
         } else {
             $input = "";
             // проверяем нет ли привязки данного поля к сязи один ко многим
             if (!empty($fieldTypeValue) && !empty($relations[$fieldTypeValue])) {
//.........这里部分代码省略.........
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:101,代码来源:CCmodelHelper.php


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