Get form manager form fields from model

@param $data
@return string
167255
private function getFormFields (stdClass $data)
    {
        $output = '';

        $output .= $this->getFields(
            $data->mainModel,
            $data->translationsLocation,
            array_merge ($this->getAutoFill(), ['id']),
            file_get_contents(__DIR__ . '/../templates/service/form/basic.field.hctpl'));

        if (isset($data->mainModel->multiLanguage))
            $output .= $this->getFields(
                $data->mainModel->multiLanguage,
                $data->translationsLocation,
                array_merge ($this->getAutoFill(), ['id', 'record_id', 'language_code']),
                file_get_contents(__DIR__ . '/../templates/service/form/multi.field.hctpl'));

        return $output;
    }
990236
protected function getFormFields()
    {
        $manyFields = $this->getManyFields();
        $formFields = [];
        foreach ($this->definition->getEditableFieldNames() as $field) {
            if (!in_array($field, $manyFields)) {
                $formFields[] = $field;
            }
        }
        return $formFields;
    }
1139813
public function determineFormStoreStrategy(ModelRelationData $data)
    {
        $type       = null;
        $parameters = [];

        // Determine strategy alias
        switch ($data->type) {

            case RelationType::BELONGS_TO:
            case RelationType::BELONGS_TO_THROUGH:
            case RelationType::MORPH_ONE:
            case RelationType::HAS_ONE:
                $type = FormStoreStrategy::RELATION_SINGLE_KEY;
                break;

            case RelationType::BELONGS_TO_MANY:
            case RelationType::HAS_MANY:
            case RelationType::MORPH_MANY:
            case RelationType::MORPH_TO_MANY:
            case RelationType::MORPHED_BY_MANY:
                $type = FormStoreStrategy::RELATION_PLURAL_KEYS;
                break;

            case RelationType::MORPH_TO:
                $type = FormStoreStrategy::RELATION_SINGLE_MORPH;
                break;
        }


        // Determine parameters

        if ($data->translated) {
            $parameters[] = 'translated';
        }

        if (count($parameters)) {
            $type .= ':' . implode(',', $parameters);
        }

        return $type;
    }
1109505
public function get_label($data) {
        global $DB;

        $role = $DB->get_record('role', array('id' => $data['value']));

        $a = new stdClass();
        $a->label = $this->_label;
        $a->value = '"'.role_get_name($role).'"';

        return get_string('globalrolelabel', 'filters', $a);
    }
104478
protected function cleanFormData(array $data)
    {
        foreach ($data as $key => $value) {
            if (\is_array($value)) {
                $data[$key] = $this->cleanFormData($value);
            } elseif (\is_object($value)) {
                unset($data[$key]);
            }
        }

        return $data;
    }
1035416
protected function getExcelData($data, \MUtil_Model_ModelAbstract $model)
    {
        $headings = array();
        $emptyMsg = $this->_('No data found.');
        foreach ($model->getItemsOrdered() as $name) {
            if ($label = $model->get($name, 'label')) {
                $headings[$name] = (string) $label;
            }
        }
        $results = array();
        $results[] = $headings;
        if ($headings) {
            if ($data) {
                foreach ($data as $row) {
                    foreach ($headings as $key => $value) {
                        $result[$key] = isset($row[$key]) ? $row[$key] : null;
                    }
                    $results[] = $result;
                }
                return $results;
            } else {
                foreach ($headings as $key => $value) {
                    $result[$key] = $emptyMsg;
                }
                $results[] = $result;
                return $results;
            }
        } else {
            return array($emptyMsg);
        }
    }
1360350
protected function applyFormats($data)
    {
        if ($this->getOptions()->getOutputFormatters()) {

            foreach ($this->getOptions()->getOutputFormatters() as $formatter) {
                if ($formatter instanceof FormatterInterface) {
                    /** @var $formatter \PageBuilder\FormatterInterface */
                    $data = $formatter->format($data);
                } elseif (is_callable($formatter)) {
                    $data = $formatter($data, $this->serviceManager);
                }
            }
        }

        return $data;
    }
323889
protected function mapFields($data)
    {
        $result = [];
        $index = 0;

        foreach ($this->csvFileFieldsOrder as $value) {
            if (!empty($value)) {
                if (strtolower($data[$index]) == 'null') {
                    $result[$value] = null;
                } else {
                    $result[$value] = $data[$index];
                }
            }
            $index++;
        }

        return $result;
    }
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);
    }
1057145
public function getFormFields($model, $multiple = false)
    {
        $formFields[] = [
            'table' => [
                'attribute' => 'table',
                'formMethod' => 'dropDownList',
                'arguments' => [
                    'items' => call_user_func(['nineinchnick\audit\models\AuditForm', 'getAuditTables'])
                ],
            ]
        ];
        foreach (Yii::$app->controller->module->filters as $propety => $params) {
            $formFields[] = static::addFormField($model, $propety, $params);
        }
        return $formFields;
    }
759707
public function getDefaultFromData($data)
    {
        if ($this->defaultFrom) {
            return $this->getFieldNameFromData($this->defaultFrom, $data);
        }

        if ($this->defaults !== '') {
            return $this->defaults;
        }

        return null;
    }
1129230
public function generateForm(array $data)
	{
		/** @var Form $form */
		$form = new $this->formClass;

		if (array_key_exists('attributes', $data))
		{
			$form->setAttributes($data['attributes']);
		}

		if (array_key_exists('content', $data))
		{
			$content = $this->generate($data['content']);
			$form->setContents($content);
		}

		return $form;
	}
209781
public static function getInputFor(\stdClass $fieldData)
    {
        $formData = explode(':', $fieldData->type->ui);
        $type = $formData[0];
        $options = isset($formData[1]) ? $formData[1] : '[]';

        if ($type == 'text' ||
            $type == 'number' ||
            $type == 'textarea' ||
            $type == 'date'
        )
        {
            return '{!! Form::' . $type . '(\'' . $fieldData->name . '\', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
        }
        elseif ($type == 'select')
        {
            $list = isset($formData[1]) ? $formData[1] : '[]';
            $options = isset($formData[2]) ? $formData[2] : '[]';

            return '{!! Form::select(\'' . $fieldData->name . '\', ' . $list . ', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
        }
        elseif ($type == 'selectRange')
        {
            $begin = isset($formData[1]) ? $formData[1] : '0';
            $end = isset($formData[2]) ? $formData[2] : '0';
            $options = isset($formData[3]) ? $formData[3] : '[]';

            return '{!! Form::selectRange(\'' . $fieldData->name . '\', ' . $begin . ', ' . $end . ', (isset($model)) ? $model->' . $fieldData->name . ' : null, ' . $options . ') !!}';
        }
        elseif ($type == 'checkbox')
        {
            $options = isset($formData[1]) ? $formData[1] : 'false';

            return '{!! Form::checkbox(\'' . $fieldData->name . '\', 1, (isset($model) && $model->' . $fieldData->name . ' == 1) ? true : false, ' . $options . ') !!}';
        }
        elseif ($type == 'radio')
        {
            array_shift($formData);
            $radioGroup = '';
            $radioId = 0;

            foreach ($formData as $value)
            {
                $radioGroup .= '{!! Form::radio(\'' . $fieldData->name . '\', \'' . $value . '\', (isset($model) && $model->' . $fieldData->name . ' == \'' . $value . '\') ? true : false, [\'id\' => ' . $radioId . ']) !!}';
                $radioId++;

                if (end($formData) != $value) $radioGroup .= PHP_EOL . "\t";
            }

            return $radioGroup;
        }
        else
        {
            throw new \Exception('Input type not implemented');
        }
    }
538683
private function getErrorFromRegData($data)
	{
		$data['username'] = e($data['username']);
		$validator = Validator::make($data, Validators::rulesForRegisterAcc(), Validators::messagesForErrors());
		$userMessages = $validator->messages();

		if ($validator->fails()) {
			$result['errors'] = array(
				'username'        => $userMessages->first('username'),
				'callback'        => $userMessages->first('callback'),
				'email'           => $userMessages->first('email'),
				'password'        => $userMessages->first('password'),
				'confirmPassword' => $userMessages->first('confirmPassword'),
			);

			return $result;
		}

		return null;
	}
248138
public function get_submitted_data() {
        $data = parent::get_submitted_data();
        if (is_object($data)) {
            foreach (static::$fieldstoremove as $field) {
                unset($data->{$field});
            }
            $data = static::convert_fields($data);
        }
        return $data;
    }
307097
private function getInputData(stdClass $data)
    {
        $output = '';
        $skip = array_merge($this->getAutoFill(), ['id']);

        if( ! empty($data->database) ) {

            if( isset($data->multiLanguage) )
                $path = '/templates/service/controller/multilanguage/input.data.hctpl';
            else
                $path = '/templates/service/controller/basic/input.data.hctpl';

            $tpl = file_get_contents(__DIR__ . '/..' . $path);

            foreach ( $data->database as $tableName => $model )
                if( array_key_exists('columns', $model) && ! empty($model->columns) && isset($model->default) )
                    foreach ( $model->columns as $column ) {
                        if( in_array($column->Field, $skip) )
                            continue;

                        $line = str_replace('{key}', $column->Field, $tpl);
                        $output .= $line;
                    }
        }

        return $output;
    }
1129103
public function convertFieldValueFromForm($data)
    {
        if ($data === null) {
            return null;
        }

        $fileData = array(
            'inputUri' => $data->getRealPath(),
            'fileName' => $data->getClientOriginalName(),
            'fileSize' => $data->getSize(),
        );

        return new FileValue($fileData);
    }