本文整理汇总了PHP中FormBuilder::classPath方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::classPath方法的具体用法?PHP FormBuilder::classPath怎么用?PHP FormBuilder::classPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::classPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: load
/**
* load
* Fungsi ini digunakan untuk me-load FormBuilder
* @param array $class
* @param array $findByAttributes
* @return mixed me-return null jika class tidak ada, jika ada maka me-return array $model
*/
public static function load($class, $findByAttributes = [])
{
if (!is_string($class)) {
return null;
}
$originalClass = $class;
if (strpos($class, ".") !== false) {
$classFile = FormBuilder::classPath($class);
$class = Helper::explodeLast(".", $classFile);
try {
Yii::import($classFile);
} catch (Exception $e) {
if (isset(Yii::app()->controller) && isset(Yii::app()->controller->module)) {
$basePath = Yii::app()->controller->module->basePath;
$classFile = str_replace(".", DIRECTORY_SEPARATOR, $classFile) . ".php";
$classFile = $basePath . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . $classFile;
require_once $classFile;
}
}
if (!class_exists($class)) {
throw new CException("Class \"{$class}\" does not exists");
}
}
$model = new FormBuilder();
if (!empty($findByAttributes) && method_exists($class, 'model')) {
if (is_subclass_of($class, 'ActiveRecord')) {
$model->model = $class::model()->findByAttributes($findByAttributes);
if (is_null($model->model)) {
$model->model = new $class();
}
}
} else {
$model->model = new $class();
}
$model->originalClass = $originalClass;
if (!is_null($findByAttributes)) {
$model->model->attributes = $findByAttributes;
}
## get method line and length
if (isset(Yii::app()->session)) {
if (is_null(Yii::app()->session['FormBuilder_' . $originalClass])) {
$reflector = new ReflectionClass($class);
$model->sourceFile = $reflector->getFileName();
$model->file = file($model->sourceFile, FILE_IGNORE_NEW_LINES);
$methods = $reflector->getMethods();
foreach ($methods as $m) {
if ($m->class == $class) {
$line = $m->getStartLine() - 1;
$length = $m->getEndLine() - $line;
$model->methods[$m->name] = ['line' => $line, 'length' => $length];
}
}
Yii::app()->session['FormBuilder_' . $originalClass] = ['sourceFile' => $model->sourceFile, 'file' => $model->file, 'methods' => $model->methods];
} else {
$s = Yii::app()->session['FormBuilder_' . $originalClass];
$model->sourceFile = $s['sourceFile'];
$model->file = $s['file'];
$model->methods = $s['methods'];
if (isset($s['timestamp'])) {
$model->timestamp = $s['timestamp'];
}
}
}
return $model;
}
示例3: render
/**
* render
* Fungsi ini untuk me-render field dan atributnya
* @return mixed me-return sebuah field dan atribut checkboxlist dari hasil render
*/
public function render()
{
$this->addClass('form-group form-group-sm flat', 'options');
$this->addClass($this->layoutClass, 'options');
$this->addClass($this->errorClass, 'options');
$this->fieldOptions['ui-tree-node'] = '';
$this->fieldOptions['ng-repeat'] = 'item in value';
$this->fieldOptions['ng-init'] = 'initItem(value, $index)';
$this->addClass('list-view-item', 'fieldOptions');
Yii::import(FormBuilder::classPath($this->templateForm));
$class = Helper::explodeLast(".", $this->templateForm);
if (($this->fieldTemplate == 'form' || $this->fieldTemplate == 'datasource') && class_exists($class)) {
$fb = FormBuilder::load($class);
$model = new $class();
if ($this->value == "") {
$this->value = [];
}
$this->templateAttributes = $model->attributes;
$fb->model = $model;
$this->renderTemplateForm = $fb->render($model, ['wrapForm' => false]);
} else {
if ($this->fieldTemplate == 'default') {
$field = new $this->singleView();
$field->attributes = $this->singleViewOption;
$field->renderID = $this->name . rand(0, 10000);
$field->builder = $this->builder;
$field->formProperties = $this->formProperties;
$this->templateAttributes = ['val' => ''];
$this->renderTemplateForm = $field->render();
}
}
$this->setDefaultOption('ng-model', "model.{$this->originalName}", $this->options);
$jspath = explode(".", FormBuilder::classPath($this->templateForm));
array_pop($jspath);
$jspath = implode(".", $jspath);
$inlineJS = str_replace("/", DIRECTORY_SEPARATOR, trim($this->inlineJS, "/"));
$inlineJS = Yii::getPathOfAlias($jspath) . DIRECTORY_SEPARATOR . $inlineJS;
if (is_file($inlineJS)) {
$inlineJS = file_get_contents($inlineJS);
} else {
$inlineJS = '';
}
return $this->renderInternal('template_render.php', ['inlineJS' => $inlineJS]);
}