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


PHP FormBuilder::load方法代码示例

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


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

示例1: validateSubForm

 public function validateSubForm()
 {
     $class = get_class($this);
     $fb = FormBuilder::load($class);
     $listView = $fb->findAllField(['type' => 'ListView']);
     foreach ($listView as $k => $lv) {
         ## if listview is valid
         if ((@$lv['fieldTemplate'] == "datasource" || @$lv["fieldTemplate"] == "form") && @$lv['templateForm'] != '') {
             if (isset($this->attributes[$lv['name']])) {
                 $items = $this->attributes[$lv['name']];
                 foreach ($items as $k => $item) {
                     Yii::import($lv['templateForm']);
                     $newClass = Helper::explodeLast(".", $lv['templateForm']);
                     $new = new $newClass();
                     $new->attributes = $item;
                     $new->validate();
                     if ($new->hasErrors()) {
                         foreach ($new->errors as $name => $errors) {
                             $this->addError($name, implode("<br> &bull; ", $errors));
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:rizabudi,项目名称:plansys,代码行数:26,代码来源:Form.php

示例2: render

 /**
  * render
  * Fungsi ini untuk me-render layout
  * @param array $layout
  * @param array $sections
  * @param array $model
  * @param boolean $return
  * @return mixed me-return sebuah layout
  */
 public static function render($layout, $sections = null, $model = null, $return = false)
 {
     $formpath = @$sections['editor'] ? '//layouts/forms_editor/' : "//layouts/forms/";
     if (count($sections) > 0) {
         foreach ($sections as $k => $section) {
             switch (@$section['type']) {
                 case "menu":
                     if (@$section['file'] == "") {
                         continue;
                     }
                     $options = ['title' => @$section['title'], 'icon' => @$section['icon'], 'sections' => $sections, 'options' => @$section['menuOptions'], 'inlineJS' => @$section['inlineJS']];
                     $mt = MenuTree::load($section['file'], $options);
                     if ($mt != null) {
                         $sections[$k]['content'] = $mt->render(false);
                     }
                     break;
                 case "form":
                     if (@$section['class'] == "") {
                         continue;
                     }
                     $fb = FormBuilder::load(@$section['class']);
                     if ($fb != null) {
                         $sections[$k]['content'] = $fb->render($model, ['renderInAjax' => true]);
                     }
                     break;
             }
         }
     }
     return Yii::app()->controller->renderPartial($formpath . $layout, $sections, $return);
 }
开发者ID:reggi49,项目名称:plansys,代码行数:39,代码来源:Layout.php

示例3: actionRenderProperties

 public function actionRenderProperties()
 {
     $properties = FormBuilder::load('RepoProperties');
     if ($this->beginCache('RepoProperties', array('dependency' => new CFileCacheDependency(Yii::getPathOfAlias('application.forms.RepoProperties') . ".php")))) {
         echo $properties->render();
         $this->endCache();
     }
 }
开发者ID:reggi49,项目名称:plansys,代码行数:8,代码来源:RepoController.php

示例4: actionCellTemplate

 public function actionCellTemplate()
 {
     $postdata = file_get_contents("php://input");
     $post = CJSON::decode($postdata);
     $fb = FormBuilder::load($post['class']);
     $field = $fb->findField(['name' => $post['name']]);
     $this->attributes = $field;
     $post['item'] = $this->processSingleColumn($post['item']);
     echo $this->getRowTemplate($post['item'], $post['idx']);
 }
开发者ID:reggi49,项目名称:plansys,代码行数:10,代码来源:GridView.php

示例5: actionSubform

 public function actionSubform($c, $f)
 {
     Yii::import($c);
     $class = Helper::explodeLast(".", $c);
     $fb = FormBuilder::load($class);
     $field = $fb->findField(['name' => $f]);
     if (!!$field) {
         $this->attributes = $field;
         $this->renderSubForm();
     }
 }
开发者ID:balitax,项目名称:plansys,代码行数:11,代码来源:PopupWindow.php

示例6: renderSubForm

 public function renderSubForm()
 {
     if ($this->subFormClass == get_class($this)) {
         return '<center><i class="fa fa-warning"></i> Error Rendering SubForm: Subform can not be the same as its parent</center>';
     } else {
         ## render
         Yii::import($this->subForm);
         $fb = FormBuilder::load($this->subFormClass);
         $render = $fb->render($fb->model, ['wrapForm' => false]);
         return $render;
     }
 }
开发者ID:reggi49,项目名称:plansys,代码行数:12,代码来源:ModalDialog.php

示例7: actionResizeCol

 public function actionResizeCol($col, $name, $size, $alias)
 {
     $fb = FormBuilder::load($alias);
     $field = $fb->findField(['name' => $name]);
     if (isset($field) && isset($field['columns'][$col])) {
         if (!isset($field['columns'][$col]['options'])) {
             $field['columns'][$col]['options'] = [];
         }
         $field['columns'][$col]['options']['width'] = $size;
     }
     $fields = $fb->updateField(['name' => $name], $field);
     $fb->setFields($fields);
 }
开发者ID:reggi49,项目名称:plansys,代码行数:13,代码来源:DataTable.php

示例8: renderHtml

 public function renderHtml()
 {
     Yii::import($this->subForm);
     $class = $this->subFormClass;
     if (!class_exists($class)) {
         return '';
     }
     $model = new $class();
     $fb = FormBuilder::load($class);
     $html = '<div ng-controller="' . $this->ctrlName . 'Controller">';
     if ($this->mode == 'single') {
         $fb->fieldNameTemplate = '' . get_class($this->model) . '[' . $this->name . '][:name]';
     }
     $this->templateAttributes = $model->attributes;
     $html .= $fb->render(null, ['wrapForm' => false]);
     $html .= '</div>';
     return $html;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:18,代码来源:SubForm.php

示例9: formbuilder_maintain

function formbuilder_maintain($name)
{
    // We need the object whether or not there are any questions in it
    $formbuilder = new FormBuilder();
    $formbuilder->load($name);
    $data = $_POST['data'];
    switch ($_POST['edit']['step']) {
        // Generate confirmation page
        case 'confirm':
            // TODO generate the confirmation; for now, just save changes
            //$rc = $formbuilder->perform_maintenance( $data );
            //$rc .= $formbuilder->render_confirmation();
            //break;
        // TODO generate the confirmation; for now, just save changes
        //$rc = $formbuilder->perform_maintenance( $data );
        //$rc .= $formbuilder->render_confirmation();
        //break;
        case 'perform':
            $rc = $formbuilder->perform_maintenance($data);
            $rc .= $formbuilder->save(true);
            $rc .= $formbuilder->render_maintenance();
            break;
        default:
            $rc = $formbuilder->render_maintenance();
    }
    return $rc;
}
开发者ID:roboshed,项目名称:leaguerunner,代码行数:27,代码来源:formbuilder.php

示例10: actionPreviewSQL

 public function actionPreviewSQL()
 {
     $postdata = file_get_contents("php://input");
     $post = json_decode($postdata, true);
     $criteria = @$post['criteria'] ? $post['criteria'] : [];
     $params = @$post['params'] ? $post['params'] : [];
     $baseClass = $post['baseclass'];
     switch ($baseClass) {
         case "DataGrid":
         case "DataFilter":
         case "RelationField":
         case "TextField":
             $rel = 'currentModel';
             $name = $post['rfname'];
             $classPath = $post['rfclass'];
             $modelClassPath = $post['rfmodel'];
             $modelClass = Helper::explodeLast(".", $modelClassPath);
             Yii::import($modelClassPath);
             $class = Helper::explodeLast(".", $classPath);
             Yii::import($classPath);
             $model = new $modelClass();
             $builder = $model->commandBuilder;
             $fb = FormBuilder::load($classPath);
             $field = $fb->findField(['name' => $name]);
             $rf = new RelationField();
             $rf->builder = $fb;
             $rf->attributes = $field;
             $rf->relationCriteria = $criteria;
             $rf->params = $post['params'];
             $criteria = $rf->generateCriteria('', []);
             $criteria = new CDbCriteria($criteria);
             break;
         case "DataSource":
             $rel = $post['rel'];
             $name = $post['dsname'];
             $classPath = $post['dsclass'];
             $class = Helper::explodeLast(".", $classPath);
             Yii::import($classPath);
             $model = new $class();
             $builder = $model->commandBuilder;
             $fb = FormBuilder::load($classPath);
             $fb->model = new $model();
             $field = $fb->findField(['name' => $name]);
             $ds = new DataSource();
             $ds->attributes = $field;
             $criteria = DataSource::generateCriteria($params, $criteria, $ds);
             $criteria = SqlCriteria::convertPagingCriteria($criteria);
             $criteria = new CDbCriteria($criteria);
             break;
     }
     if (!isset($rel)) {
         echo json_encode(["sql" => '', "error" => '']);
         return false;
     }
     $isRelated = false;
     if ($rel == 'currentModel') {
         $tableSchema = $model->tableSchema;
     } else {
         $parent = $model::model()->find();
         $relMeta = $model->getMetadata()->relations[$rel];
         $relClass = $relMeta->className;
         if (!is_subclass_of($relClass, 'ActiveRecord')) {
             throw new CException("Class {$relClass} harus merupakan subclass dari ActiveRecord");
         }
         $tableSchema = $relClass::model()->tableSchema;
         if (!is_null($parent)) {
             $parentPrimaryKey = $parent->metadata->tableSchema->primaryKey;
             switch (get_class($relMeta)) {
                 case 'CHasOneRelation':
                 case 'CBelongsToRelation':
                     if (is_string($relMeta->foreignKey)) {
                         $criteria->addColumnCondition([$relMeta->foreignKey => $parent->{$parentPrimaryKey}]);
                         $isRelated = true;
                     }
                     break;
                 case 'CManyManyRelation':
                     $parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative());
                     $stmts = $parser->parse('<?php ' . $relMeta->foreignKey . ';');
                     $bridgeTable = $stmts[0]->name->parts[0];
                     $arg0 = $stmts[0]->args[0]->value->name->parts[0];
                     $arg1 = $stmts[0]->args[1]->value->name->parts[0];
                     $criteria->join .= " " . $relMeta->joinType . " {$bridgeTable} ON t.{$tableSchema->primaryKey} = {$bridgeTable}.{$arg1} ";
                     break;
                 case 'CHasManyRelation':
                     //without through
                     if (is_string($relMeta->foreignKey)) {
                         $criteria->addColumnCondition([$relMeta->foreignKey => $parent->{$parentPrimaryKey}]);
                         $isRelated = true;
                     }
                     //with through
                     //todo..
                     break;
             }
         }
     }
     $command = $builder->createFindCommand($tableSchema, $criteria);
     $commandText = $command->text;
     if ($isRelated) {
         $commandText = str_replace(":ycp0", "\n" . '"{$model->' . $relMeta->foreignKey . '}"', $commandText);
     }
//.........这里部分代码省略.........
开发者ID:balitax,项目名称:plansys,代码行数:101,代码来源:SqlCriteria.php

示例11: doAfterSave

 public function doAfterSave($withRelation = true)
 {
     $pk = $this->tableSchema->primaryKey;
     if ($this->isNewRecord) {
         $this->{$pk} = $this->dbConnection->getLastInsertID();
         ## this is hack
         ## UPDATE AUDIT TRAIL 'CREATE' ID
         if (!!Yii::app()->user && !Yii::app()->user->isGuest) {
             $a = $this->dbConnection->createCommand("\n                update p_audit_trail set model_id = :model_id\n                WHERE user_id = :user_id and\n                model_class = :model_class and\n                type = 'create' and\n                model_id is null")->execute(['model_class' => ActiveRecord::baseClass($this), 'model_id' => $this->{$pk}, 'user_id' => Yii::app()->user->id]);
         }
     } else {
         $this->deleteResetedRelations();
     }
     if ($withRelation) {
         $this->saveRelation();
     }
     ## handling untuk file upload
     if (method_exists($this, 'getFields')) {
         $fb = FormBuilder::load(get_class($this));
         $uploadFields = $fb->findAllField(['type' => 'UploadFile']);
         $attrs = [];
         $model = $this;
         foreach ($uploadFields as $k => $f) {
             if (@$f['name'] == '' || @$f['uploadPath'] == '') {
                 continue;
             }
             ## create directory
             ## Jika disini gagal, berarti ada yang salah dengan format uploadPath di FormBuilder-nya
             $evalDir = '';
             eval('$evalDir = "' . $f['uploadPath'] . '";');
             $evalDir = str_replace(["\n", "\r"], "", $evalDir);
             $repopath = realpath(Yii::getPathOfAlias("repo"));
             $evalDirArr = explode("/", $evalDir);
             foreach ($evalDirArr as $i => $j) {
                 $evalDirArr[$i] = preg_replace('/[\\/\\?\\:\\*\\"\\<\\>\\|\\\\]*/', "", $j);
             }
             $evalDir = implode("/", $evalDirArr);
             $dir = $repopath . "/" . $evalDir . "/";
             $dir = str_replace(["\n", "\r"], "", $dir);
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
             }
             ## get oldname
             $old = $this->{$f['name']};
             $ext = pathinfo($old, PATHINFO_EXTENSION);
             $filename = pathinfo($old, PATHINFO_FILENAME);
             if (@$f['filePattern']) {
                 ## get newname
                 ## Jika disini gagal, berarti ada yang salah dengan format filePattern di FormBuilder-nya
                 eval('$newname = "' . $f['filePattern'] . '";');
             } else {
                 $newname = $filename . "." . $ext;
             }
             $new = $dir . preg_replace('/[\\/\\?\\:\\*\\"\\<\\>\\|\\\\]*/', "", $newname);
             $new = str_replace(["\n", "\r"], "", $new);
             ## delete file if already exist and allowed to overwrite
             if (is_file($new) && $f['allowOverwrite'] == 'Yes' && is_file($old)) {
                 unlink($new);
             }
             if (!is_file($new) && is_file($old)) {
                 rename($old, $new);
                 $this->{$f['name']} = trim($evalDir, "/") . "/" . $newname;
                 if ($this->hasAttribute($f['name'])) {
                     $attrs[] = $f['name'];
                 }
             }
         }
         if (count($attrs) > 0) {
             if ($this->isNewRecord) {
                 $this->isNewRecord = false;
                 $this->updateByPk($this->id, $this->getAttributes($attrs));
                 $this->isNewRecord = true;
             } else {
                 $this->update($attrs);
             }
         }
     }
     return true;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:79,代码来源:ActiveRecord.php

示例12:

<?php

FormField::$inEditor = false;
?>

    <div class="properties-header">
        <div ng-if="propMsg != 'Loading Field'">
            <i class="fa fa-file-text"></i>&nbsp;
            Form Properties
        </div>
        <div ng-if="propMsg == 'Loading Field'">
            <i class="fa fa-spin fa-refresh"></i> Loading Field...
        </div>
    </div>

    <div ui-content style="padding:6px 5px 0px 10px;">
        <?php 
$fp = FormBuilder::load('DevFormProperties');
echo $fp->render($fb->form);
?>
    </div>
<?php 
FormField::$inEditor = true;
开发者ID:reggi49,项目名称:plansys,代码行数:23,代码来源:form_properties.php

示例13: actionUpdate

 public function actionUpdate($class)
 {
     FormField::$inEditor = true;
     $isPHP = Helper::explodeLast(".", $class);
     $class = $isPHP == "php" ? substr($class, 0, -4) : $class;
     $class = FormBuilder::classPath($class);
     $this->layout = "//layouts/blank";
     ## reset form builder session
     FormBuilder::resetSession($class);
     ## load form builder class and session
     $fb = FormBuilder::load($class);
     $fb->resetTimestamp();
     $fb->updateExtendsFrom('Blog');
     $classPath = $class;
     $class = Helper::explodeLast(".", $class);
     if (is_subclass_of($fb->model, 'ActiveRecord')) {
         $formType = "ActiveRecord";
         FormsController::setModelFieldList($class::model()->getAttributesList(), "AR", $class);
     } else {
         if (is_subclass_of($fb->model, 'FormField')) {
             $formType = "FormField";
             $mf = new $class();
             FormsController::setModelFieldList($mf->attributes, "FF");
         } else {
             if (is_subclass_of($fb->model, 'Form')) {
                 $formType = "Form";
                 $mf = new $class();
                 FormsController::setModelFieldList($mf->attributes, "FF");
             }
         }
     }
     $fieldData = $fb->fields;
     FormsController::$modelField = $fieldData;
     $toolbar = $this->renderAllToolbar($formType);
     Yii::import('application.modules.' . $fb->module . '.controllers.*');
     echo $this->render('form', array('fb' => $fb, 'class' => $class, 'classPath' => $classPath, 'formType' => $formType, 'moduleName' => Helper::explodeFirst(".", $classPath), 'toolbarData' => @$toolbar['data'], 'fieldData' => $fieldData), true);
 }
开发者ID:balitax,项目名称:plansys,代码行数:37,代码来源:FormsController.php

示例14: doAfterSave

 public function doAfterSave($withRelation = true)
 {
     $pk = $this->tableSchema->primaryKey;
     if ($this->isNewRecord) {
         $this->{$pk} = $this->dbConnection->getLastInsertID();
         ## this is hack
         ## UPDATE AUDIT TRAIL 'CREATE' ID
         if (!!Yii::app()->user && !Yii::app()->user->isGuest) {
             $a = $this->dbConnection->createCommand("\n                update p_audit_trail set model_id = :model_id\n                WHERE user_id = :user_id and\n                model_class = :model_class and\n                type = 'create' and\n                model_id is null")->execute(['model_class' => ActiveRecord::baseClass($this), 'model_id' => $this->{$pk}, 'user_id' => Yii::app()->user->id]);
         }
     } else {
         $this->deleteResetedRelations();
     }
     if ($withRelation) {
         foreach ($this->__relations as $k => $new) {
             if ($k == 'currentModel') {
                 $rel = new CHasManyRelation('currentModel', get_class($this), 'id');
             } else {
                 $rel = $this->getMetaData()->relations[$k];
             }
             $relClass = $rel->className;
             if (!class_exists($relClass)) {
                 continue;
             }
             $relType = get_class($rel);
             $relForeignKey = $rel->foreignKey;
             $relTableModel = $relClass::model();
             $relTable = $relTableModel->tableName();
             $relPK = $relTableModel->metadata->tableSchema->primaryKey;
             switch ($relType) {
                 case 'CHasOneRelation':
                 case 'CBelongsToRelation':
                     if (!empty($new)) {
                         $relForeignKey = $rel->foreignKey;
                         if ($this->{$relForeignKey} == $new[$relPK]) {
                             $model = $relClass::model()->findByPk($this->{$relForeignKey});
                             if (is_null($model)) {
                                 $model = new $relClass();
                             }
                             if (array_diff($model->attributes, $new)) {
                                 $model->attributes = $new;
                                 if ($relType == 'CHasOneRelation') {
                                     $model->{$relForeignKey} = $this->{$pk};
                                 }
                                 $model->save();
                             }
                         } else {
                             $this->loadRelation($rel->name);
                         }
                     }
                     break;
                 case 'CManyManyRelation':
                 case 'CHasManyRelation':
                     ## if relation type is Many to Many, prepare required variable
                     $relMM = [];
                     if ($relType == 'CManyManyRelation') {
                         $parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative());
                         $stmts = $parser->parse('<?php ' . $relForeignKey . ';');
                         if (count($stmts) > 0) {
                             $relMM = ['tableName' => $stmts[0]->name->parts[0], 'from' => $stmts[0]->args[0]->value->name->parts[0], 'to' => $stmts[0]->args[1]->value->name->parts[0]];
                         }
                     }
                     ## Handle Insert
                     if (isset($this->__relInsert[$k])) {
                         if ($k != 'currentModel') {
                             if (is_string($relForeignKey)) {
                                 ## without through
                                 if ($relType != 'CManyManyRelation') {
                                     foreach ($this->__relInsert[$k] as $n => $m) {
                                         $this->__relInsert[$k][$n][$relForeignKey] = $this->{$pk};
                                     }
                                 }
                             } else {
                                 if (is_array($relForeignKey)) {
                                     ## with through
                                     foreach ($this->__relInsert[$k] as $n => $m) {
                                         foreach ($relForeignKey as $rk => $fk) {
                                             $this->__relInsert[$k][$n][$fk] = $this->__relations[$rel->through][$rk];
                                         }
                                     }
                                 }
                             }
                         }
                         if (count($this->__relInsert[$k]) > 0) {
                             if ($relType == "CHasManyRelation") {
                                 ActiveRecord::batchInsert($relClass, $this->__relInsert[$k]);
                             }
                             ## if current relation is many to many
                             if ($relType == 'CManyManyRelation' && !empty($relMM)) {
                                 $manyRel = [];
                                 foreach ($this->__relInsert[$k] as $item) {
                                     $manyRel[] = [$relMM['from'] => $this->{$pk}, $relMM['to'] => $item[$relPK]];
                                 }
                                 ## if relinsert is already exist, then do not insert it again
                                 foreach ($this->__relInsert[$k] as $insIdx => &$ins) {
                                     if (!!@$ins[$relPK]) {
                                         unset($this->__relInsert[$k]);
                                     }
                                 }
                                 ActiveRecord::batchInsert($relClass, $this->__relInsert[$k]);
//.........这里部分代码省略.........
开发者ID:balitax,项目名称:plansys,代码行数:101,代码来源:ActiveRecord.php

示例15: array

<?php

FormField::$inEditor = false;
?>

<div class="properties-header">
    <div class='btn btn-default btn-xs pull-right '
         ng-click='unselectLayout();'>
        <i class='fa fa-times'></i>
        Close
    </div>
    <i class = "fa fa-file-text"></i>&nbsp;
    Form Layout <span class="label label-default">{{layout.name | uppercase }}</span>
</div>

<div ui-content style="padding:6px 0px 0px 0px;">
    <?php 
$fpl = FormBuilder::load('DevFormLayoutProperties', array('module' => $fb->module));
echo $fpl->render();
?>
</div>
<?php 
FormField::$inEditor = true;
开发者ID:reggi49,项目名称:plansys,代码行数:23,代码来源:form_layout.php


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