@param string $form_name
@param array $data

@return null|string
@throws \yii\base\Exception
@throws \yii\base\InvalidConfigException
191802
public static function upload($form_name = 'file', $data = [])
    {
        $settings = \Yii::$app->settings;
        if (!empty($data['quality'])) {
            $quality = $data['quality'];
        } else {
            $quality = Media::getConfigurationQuality(50);
        }
        $file = UploadedFile::getInstanceByName($form_name);
        if ($file) {
            $file->name = str_replace([' ', '(', ')'], '-', trim(addslashes($file->name)));
            $uploadDir = self::getUploadDir();
            FileHelper::createDirectory(self::getUploadDir() . '/' . date('Y/m/d'));
            $fileName = date('Y/m/d') . '/' . date('his') . '-' . $file->name;
            $fileName_save = $uploadDir . '/' . $fileName;
            $file->saveAs($fileName_save);
            Image::getImagine()->open($fileName_save)->save($fileName_save, ['quality' => $quality]);
            $url = 'uploads/' . $fileName;

            $media = new Media([
                'name' => $file->name,
                'path' => $url,
                'type' => FileHelper::getMimeType($fileName_save),
                'file_size' => filesize($fileName_save),
                'dimensions' => getimagesize($fileName_save)[0] . 'x' . getimagesize($fileName_save)[1],
            ]);
            if (!empty($data['title'])) {
                $media->title = $data['title'];
            }
            if (!empty($data['caption'])) {
                $media->caption = $data['caption'];
            }
            if (!empty($data['alt'])) {
                $media->alt = $data['alt'];
            }
            if (!empty($data['description'])) {
                $media->description = $data['description'];
            }
            if (!\Yii::$app->user->isGuest) {
                $media->created_by = \Yii::$app->user->id;
            }
            $media->save();

            /**
             * Generate All Other size
             */
            if (empty($thumbnailDir)) {
                $thumbnailDir = \Yii::getAlias('@thumbnail');
            }
            FileHelper::createDirectory($thumbnailDir . '/' . date('Y/m/d'));
            $thumbnail_save = $thumbnailDir . '/' . $fileName;
            $thumbnail_size_width = Media::getConfigurationThumbnailSizeWidth();
            $thumbnail_size_height = Media::getConfigurationThumbnailSizeHeight();
            Image::getImagine()->open($fileName_save)->thumbnail(new Box($thumbnail_size_width, $thumbnail_size_height))->save($thumbnail_save , ['quality' => $quality]);
            if (empty($mediumDir)) {
                $mediumDir = \Yii::getAlias('@medium');
            }
            FileHelper::createDirectory($mediumDir. '/' . date('Y/m/d'));
            $medium_save = $mediumDir . '/' . $fileName;
            $medium_size_width = Media::getConfigurationMediumSizeWidth();
            $medium_size_height = Media::getConfigurationMediumSizeHeight();
            Image::getImagine()->open($fileName_save)->thumbnail(new Box($medium_size_width, $medium_size_height))->save($medium_save , ['quality' => $quality]);
            if (empty($largeDir)) {
                $largeDir = \Yii::getAlias('@large');
            }
            FileHelper::createDirectory($largeDir . '/' . date('Y/m/d'));
            $large_save = $largeDir  . '/' . $fileName;
            $large_size_width = Media::getConfigurationLargeSizeWidth();
            $large_size_height = Media::getConfigurationLargeSizeHeight();
            Image::getImagine()->open($fileName_save)->thumbnail(new Box($large_size_width, $large_size_height))->save($large_save , ['quality' => $quality]);
            return $url;
        } else {
            return null;
        }
    }
1246802
public function validate($name, $data, $format = null)
    {
        if (!is_string($data)) {
            throw new Exception("propriedade [ {$name} ] é inválida para tipo [ string ] definido no schema", 400);
        }

        if ($format) {
            $data = self::applyFormat($format, $data);
        }

        return (string)$data;
    }
650561
public function contentEdit(
        ?ContentEditData $data = null,
        ?string $name = null,
        array $options = []
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentEditType::class);
        $data = $data ?? new ContentEditData();

        if (empty($options['language_codes']) && null !== $data->getVersionInfo()) {
            $options['language_codes'] = $data->getVersionInfo()->languageCodes;
        }

        return $this->formFactory->createNamed(
            $name,
            ContentEditType::class,
            $data,
            $options
        );
    }
927623
function formData(form) {
    var length = form.length;
    var data = {};
    var value;
    var el;
    var type;
    var name;

    var append = function (data, name, value) {
      if (data[name] === undefined) {
        data[name] = value;
      } else {
        if (typeof data[name] === 'string') {
          data[name] = [data[name]];
        }
        data[name].push(value);
      }
    };

    for (var i = 0; i < length; i++) {
      el = form[i];
      value = el.value;
      type = el.type;
      name = el.name;

      if (type === 'radio') {
        if (el.checked) {
          append(data, name, value);
        }
      } else if (type === 'checkbox') {
        if (data[name] === undefined) {
          data[name] = [];
        }
        if (el.checked) {
          append(data, name, value);
        }
      } else {
        append(data, name, value);
      }
    }

    return data;
  }
1314969
protected function renderHtml($name = null, $data = []) {
        if (is_array($name)) {
            $data = $name;
            $name = null;
        }
        return $this->renderFile($this->getViewFile($name), $data);
    }
583641
static function autoform($form_array)
	{
		$forms = array();
		foreach($form_array as $k=>$v)
		{
		    //表单类型
			$func = $v['type'];
			//表单值
			$value = '';
			if(isset($v['value'])) $value = $v['value'];
			unset($v['type'],$v['value']);

			if($func=='input' or $func=='password' or $func=='text' or $func=='htmltext')
			{
			    $forms[$k] = self::$func($k,$value,$v);
			}
			else
			{
			    $option = $v['option'];
	            $self = $v['self'];
	            $label_class = $v['label_class'];
			    unset($v['option'],$v['self'],$v['label_class']);
			    $forms[$k] = self::$func($k,$option,$value,$self,$v,$label_class);
			    if($func=='radio' and isset($v['empty']))
			        $forms[$k].= "\n<script language='javascript'>add_filter('{$k}','{$v['empty']}',function(){return getRadioValue('{$k}');});</script>";
			    elseif($func=='checkbox' and isset($v['empty']))
			        $forms[$k].= "\n<script language='javascript'>add_filter('{$k}[]','{$v['empty']}',function(){return getCheckboxValue('{$k}[]');});</script>";
			}
		}
		return $forms;
	}
329005
public function deleteTrashItem(
        TrashItemDeleteData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(TrashItemDeleteType::class);

        return $this->formFactory->createNamed($name, TrashItemDeleteType::class, $data);
    }
1238863
public function getForm(string $name = '', array $form = null)
    {
        if (!isset($this->_forms[$name])) {
            $this->_forms[$name] = $this->createFormObject($name, $form);
        }

        return $this->_forms[$name];
    }
958720
public function createNamedFormBuilder($name = 'form', $data = null, array $options = array())
    {
        return $this->getFormFactory()->createNamedBuilder($name, FormType::class, $data, $options);
    }
762943
public function contentTypeEdit(
        ContentTypeEditData $data = null,
        ?string $name = null,
        array $options = []
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentTypeEditType::class);

        return $this->formFactory->createNamed($name, ContentTypeEditType::class, $data, $options);
    }
309666
public function getFormPageByFormName($formName)
    {
        if ($formPage = $this->getFormPages()->filter(
            function($formPage) use($formName) {
                /** @var FormDocument $form */
                if ($form = $formPage->getForm()) {
                    if ($form->getName() == $formName) {
                        return true;
                    }
                }

                return false;
            }
        )->first()) {
            return $formPage;
        }

        return null;
    }
9989
static function getDataValidator($data, $form = null) {
        $v = static::getVendor();
        if ($v) {
            $v .= '::';
        }
        $filters = (array)\Config::get($v . 'models/' . static::getEntity() . '/filters');
        $rules   = (array)\Config::get($v . 'models/' . static::getEntity() . '/rules');
        $rules = Arr::only($rules, array_keys($data));
//        dump($data);
//        dd($rules);





        //        dump($rules);
        //        \Debugbar::addMessage($rules);
        \Debugbar::addMessage($data);
        $labels   = static::getEntityLabels();
        $messages = static::getEntityValidationMessage();
        \Debugbar::addMessage($labels);
        \Debugbar::addMessage($messages);
        foreach ($filters as $field => $field_filters) {
            //            $field_filters = ['trim'] + $field_filters;
            foreach ($field_filters as $field_filter) {
                $elements  = $form ? $form->getElementsByName($field) : [];
                $options   = [];
                $options[] = Arr::get($data, $field);
                if ($field_filter instanceof \Closure) {
                    $options[] = $data;
                    $options[] = $elements;
                }
                if (isset($data[$field])) {
                    $data[$field] = call_user_func_array($field_filter, $options);
                }
            }
        }
        $class     = static::getClassDataValidator();
        $validator = new $class;

        return $validator->setData((array)$data)->setRules((array)$rules)->setLabels((array)$labels)->setMessages((array)$messages);
    }
848474
public function deleteRoles(
        RolesDeleteData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: sprintf('delete-roles');

        return $this->formFactory->createNamed($name, RolesDeleteType::class, $data);
    }
652532
public function deleteTranslation(
        TranslationDeleteData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: sprintf('delete-translations');

        return $this->formFactory->createNamed($name, TranslationDeleteType::class, $data);
    }
908131
private static function _array(&$data, $name)
	{
		?>
		<li class="krumo-child">

			<div <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
				class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>">

					<a class="krumo-name"><?php echo $name;?></a>
					(<em class="krumo-type">Array, <strong class="krumo-array-length"><?php echo
						(count($data)==1)
							? ('1 element')
							: (count($data) . ' elements');
						?></strong></em>)
					<?php

					// callback ?
					//
					if (is_callable($data))
					{
						$_ = array_values($data);
						?>
						<span class="krumo-callback"> |
							(<em class="krumo-type">Callback</em>)
							<strong class="krumo-string"><?php
								echo htmlSpecialChars($_[0]);?>::<?php
								echo htmlSpecialChars($_[1]);?>();</strong></span>
						<?php
					}
				?>
			</div>

			<?php if (count($data))
			{
				self::_vars($data);
			} ?>
		</li>
		<?php
	}
46436
public function createUrlEditForm(
        URLUpdateData $data = null,
        ?string $name = null,
        array $options = []
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(SearchData::class);

        return $this->formFactory->createNamed($name, URLEditType::class, $data, $options);
    }
277579
public function load($request, $formName = null) {
        $data = $request->getBodyParams();
        $keys = array_keys($this->getAttributes());

        if ($formName == null) {
            foreach($keys as $key) {
                if (isset($data[$key]) && !is_array($data[$key])) {
                    $this->setAttribute($key,$data[$key]);
                }
            }
            return true;
        } elseif (isset($data[$formName])) {
            foreach($keys as $key) {
                if (isset($data[$formName][$key]) && !is_array($data[$formName][$key])) {
                    $this->setAttribute($key,$data[$formName][$key]);
                }
            }
            return true;
        } else {
            return false;
        }
    }