1 ШАГ. ЗАГРУЖАЕМ ДВЕ МОДЕЛИ (ОСНОВНУЮ И МОДЕЛЬ С ДАННЫМИ)
@param array $data
@param null $formName
@return bool
17513
public function load($data, $formName = null)
    {
        $ret = parent::load($data, $formName); // TODO: Change the autogenerated stub
        $scope = $formName === null ? (new DataProperties())->formName() : $formName;
        if ($scope === '' && !empty($data)) {
            $this->dataProperties->setAttributes($data);
        } elseif (isset($data[$scope])) {
            $_data = $data[$scope];
            if(!empty($_data)) $this->dataProperties->setAttributes($_data);
        }
        return $ret;
    }
766618
public function php($data)
    {
        // Is Server-side Validation Enabled?
        
        if (!$this->getServerSide()) {
            return true;
        }
        
        // Initialise:
        
        $valid = true;
        
        // Validate Fields:
        
        foreach ($this->getFormFields() as $field) {
            $valid = ($field->validate($this) && $valid);
        }
        
        // Validate Rules:
        
        foreach ($this->rules as $fieldName => $rules) {
            
            if ($field = $this->getDataField($fieldName)) {
                
                foreach ($rules as $rule) {
                    
                    // Test Field Data:
                    
                    if (!$rule->test($data[$fieldName])) {
                        $this->validationError($fieldName, $rule->getMessage(), 'validation');
                        $valid = false;
                    }
                    
                }
                
            }
            
        }
        
        // Answer Result:
        
        return $valid;
    }
1361611
protected function _setViewData($formName)
    {
        $this->controller()->request->data($formName, $this->parameters()->viewValues());
        $this->controller()->set('searchParameters', $this->parameters());
    }
540312
public function emptyTrash(
        TrashEmptyData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(TrashEmptyType::class);

        return $this->formFactory->createNamed($name, TrashEmptyType::class, $data);
    }
939551
public function createLanguage(
        ?LanguageCreateData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(LanguageCreateType::class);

        return $this->formFactory->createNamed(
            $name,
            LanguageCreateType::class,
            $data ?? new LanguageCreateData()
        );
    }
1213855
public function validate(array $data = null)
    {
        $data = $data ?: $this->getInput();

        $this->validation = $this->validator->make($data, $this->rules(), $this->messages());

        if ($this->validation->fails())
        {
            $this->failed();

            return false;
        }

        return true;
    }
1209914
protected function _trigger($eventName, Subject $data = null)
    {
        return $this->_crud()->trigger($eventName, $data);
    }
815099
public static function trigger($event, $data = null)
	{
		if (!is_array($data)) {
			$data = array($data);
		}

		if (empty(self::$events[$event])) {
			return true;
		}
		
		foreach (self::$events[$event] as $callback) {
			if (!is_callable($callback)) {
				continue;
			}
			call_user_func_array($callback, $data);
		}
		
		return true;
	}
1281322
private function isValid(string $idName, array $data)
    {
        foreach ($data as $item) {
            if (!is_array($item) || !array_key_exists($idName, $item)) {
                return false;
            }
        }

        return true;
    }
560685
public function update(array $data)
    {
        // setup the custom options
        foreach ($this->getCustomOptions() as $key => $value) {
            if (isset($data[$value]) && $data[$value] == 'custom' && $data[$value . '_custom'] != '') {
                $data['_form_' . $value] = $data[$value];
                $data[$value] = $data[$value . '_custom'];
            }
        }
        
        foreach ($data as $key => $value) {
            if (in_array($key, $this->getSerialized())) {
                $value = (is_array($value) ? serialize($value) : serialize(array(
                    $value
                )));
            }
            
            if (in_array($key, $this->getEncrypted()) && $value != '') {
                $value = $this->getEncrypt()->encode($value);
            }
            
            $this->updateSetting($key, $value);
        }
        
        return true;
    }
1190230
public function deleteSections(
        SectionsDeleteData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(SectionsDeleteType::class);

        return $this->formFactory->createNamed($name, SectionsDeleteType::class, $data);
    }
1295610
public function createDefinitionForm($data): ?FormBuilderInterface
    {
        if (!$this->context->getDefinition()->hasMeta('form')) {
            return null;
        }

        $formConfig = $this->context->getDefinition()->getMeta('form') ?? [];
        $formType = $formConfig['type'] ?? null;
        if (!$formConfig || !$formType) {
            throw new \RuntimeException(sprintf('Can`t find a valid form for %s', $this->context->getDefinition()->getName()));
        }

        $options = [
            'allow_extra_fields' => true,
            'endpoint' => $this->context->getEndpoint()->getName(),
        ];

        if ($this->container->hasParameter('form.type_extension.csrf.enabled')
            && $this->container->getParameter('form.type_extension.csrf.enabled')) {
            $options['csrf_protection'] = false;
        }

        $options = array_merge($options, $formConfig['options'] ?? []);

        return $this->createFormBuilder($formType, $data, $options);
    }
1173205
public function check_data($formdata) {
        $field    = $this->_name;
        $role     = $field .'_rl';
        $category = $field .'_ct';

        if (array_key_exists($field, $formdata)) {
            if (empty($formdata->$field) and empty($formdata->$role) and empty($formdata->$category)) {
                // Nothing selected.
                return false;
            }
            return array('value'      => (string)$formdata->$field,
                         'roleid'     => (int)$formdata->$role,
                         'categoryid' => (int)$formdata->$category);
        }
        return false;
    }
142042
public function doDelete($data, Form $form) {
        $record=$this->currentPage();
    
        if($record->canDelete()) {
            Session::set('CodeBank.deletedSnippetID', $record->ID);
            $record->delete();
    
            $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_DELETED', '_Snippet has been deleted')));
        }else {
            $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.PERMISSION_DENIED', '_Permission Denied')));
        }
        
        $this->redirect('admin/codeBank/');
        return $this->getResponseNegotiator()->respond($this->request);
    }
730502
public function verify($token, $data=null)
    {
        $form_name = $this->getDefaultFormName();
        $token || $token = isset($_POST[$form_name]) ? $_POST[$form_name] : (isset($_GET[$form_name]) ? $_GET[$form_name] : null);
        
        if (!$token) {
            return ErrorInfo::error('需要 form_token 参数');
        }
        
        return parent::verify($token, $data);
    }
43641
public function register(array $data)
    {
        $class = $this->getOptions()->getUserEntityClass();
        $user  = new $class;
        $form  = $this->getRegisterForm();
        $form->setHydrator($this->getFormHydrator());
        $form->bind($user);
        $form->setData($data);
        if (!$form->isValid()) {
            return false;
        }

        $user = $form->getData();
        /* @var $user \ZfcUser\Entity\UserInterface */

        $bcrypt = new Bcrypt;
        $bcrypt->setCost($this->getOptions()->getPasswordCost());
        $user->setPassword($bcrypt->create($user->getPassword()));

        if ($this->getOptions()->getEnableUsername()) {
            $user->setUsername($data['username']);
        }
        if ($this->getOptions()->getEnableDisplayName()) {
            $user->setDisplayName($data['display_name']);
        }

        // If user state is enabled, set the default state value
        if ($this->getOptions()->getEnableUserState()) {
            $user->setState($this->getOptions()->getDefaultUserState());
        }
        $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user, 'form' => $form));
        $this->getUserMapper()->insert($user);
        $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $user, 'form' => $form));
        return $user;
    }
631885
public function render($templateName = null, $data = [])
    {
        $this->setTemplate($templateName, $data);

        return json_encode($this->_data);
    }