Render fields into appropriate format for an item creation form.

@param $fields

@return string
962854
public function formCreate($fields)
    {
        $output = '';

        foreach ($fields as $f) {
            $ucF = ucfirst($f);

            $input_attr = [
                'class' => 'form-control',
                'id' => 'createItem'.$f,
                'name' => $f,
            ];

            $label = $this->humanReadableField($ucF);

            $output .= '<fieldset class="form-group">';

            $output .= '<label for="'.$input_attr['id'].'">'.$label.'</label>';

            if ($this->isIdField($f)) {
                $input_attr['type'] = 'select';

                $output .= '<select ';
                foreach ($input_attr as $attr => $value) {
                    $output .= "{$attr}='{$value}'";
                }

                $relation = $this->crudApi->getRelatedModel($f);
                $output .= '>';

                $output .= $this->crudApi->getRelatedOptions($relation);

                $output .= '</select>';
            } else {
                $input_attr['type'] = 'text';

                $output .= '<input ';
                foreach ($input_attr as $attr => $value) {
                    $output .= "{$attr}='{$value}'";
                }
                $output .= '>';
            }

            $output .= '</fieldset>';
        }

        return $output;
    }
1371320
public function mapFormFields($fields)
    {
        $_fields = [];

        foreach ($fields as $key => $options) {
            $_options = $this->config('formFieldOptions');

            if (is_array($options)) {
                $_fields[$key] = array_merge($_options, $options);
            } else {
                $_fields[$options] = $_options;
            }
        }

        return $_fields;
    }
130638
public static function cleanFields($fields)
    {
        $fields = parent::cleanFields($fields);
        if (('*' !== array_get($fields, 0)) && !in_array('private', $fields)) {
            $fields[] = 'private';
        }

        return $fields;
    }
975119
private function render(Field $field)
    {
        $field->set('lang', $this->language);
        $field->set('prefix', $this->buildPrefix($field));

        foreach ($this->fill($field->getAttributes()) as $key => $value) {
            $field->set($key, $value);
        }

        return $field->render();
    }
46076
public function fields(string $fields): object
    {
        if (empty($this->container[$this->id]['s']['fields'])) {
            $this->container[$this->id]['s']['fields'] = "$fields";
        } else if ($this->container[$this->id]['s']['fields'] != '*') {
            $this->container[$this->id]['s']['fields'] .= ",$fields";
        }
        if ($fields == '*') {
            $this->container[$this->id]['s']['fields'] = '*';
        }
        return $this;
    }
866516
protected function fields(array $fields)
    {
        $result = array();
        foreach ($fields as $id => $field) {
            if (!isset($field['id'])) {
                $field['id'] = $id;
            }
            if (!isset($field['name'])) {
                $field['name'] = $id;
            }
            $result[$id] = $this->field($field);
        }
        return $result;
    }
580138
protected function renderAttributes($attributes)
    {
        if (count((array) $attributes) == 0) {
            return '';
        }

        $return = [];

        foreach ($attributes as $key => $value) {
            $return[] = $key . '="' . $value . '"';
        }

        return ' ' . implode(' ', $return);
    }
1360786
public static function fieldListToUpdateString($fields)
    {
        $formattedFields = [];
        foreach ($fields as $field) {
            $fieldWithEqualsColonPrefix = $field . ' = :' . $field;
            $formattedFields[] = $fieldWithEqualsColonPrefix;
        }

        return ' ' . implode(', ', $formattedFields) . ' ';
    }
892087
private function _getPreparedFields(array $pFields)
    {
        $fields = array();
        $keys   = array_keys($pFields);
        foreach ($keys as $key) {
            $fields[] = "`$key` = ?";
        }

        return implode(', ', $fields);
    }
347999
protected function formatFieldName(string $field): string {
        if ($this->getTranslateFieldNames()) {
            return $this->translate($field);
        } else {
            return $field;
        }
    }
817935
public function render_field($field)
    {
        /*
        *  Review the data of $field.
        *  This will show what data is available
        */

        /**
         * TODO
         *
         * => Render out icons within the select options
         */


        //echo '<pre>';
        //print_r($field);
        //echo '</pre>';

        if (!is_array($this->dropdownOptions($field)) || empty($this->dropdownOptions($field))) {
            return;
        }

        $output = '';

        $output .= '<select class="c-pricons-dropdown" name="' . $field['name'] . '">';

        if ($field['value'] == "") {
            $output .= '<option class="c-pricons-dropdown__option" value="" selected>Select an icon</option>';
        } else {
            $output .= '<option class="c-pricons-dropdown__option" value="">Select an icon</option>';
        }


        foreach ($this->dropdownOptions($field) as $value => $label) {
            if ($value == $field['value']) {
                $output .= '<option class="c-pricons-dropdown__option" value="' . $value . '" selected>' . $label . '</option>';
            } else {
                $output .= '<option class="c-pricons-dropdown__option" value="' . $value . '">' . $label . '</option>';
            }
        }

        $output .= '</select>';

        echo $output;
    }
191335
public function createFields($fields = null): string
    {
        // 如果未指定字段,则,全部字段
        if (!$fields) {
            return '*';
        }

        $ret = $this->formatFields($fields);

        // 返回逗号分隔的列表
        return implode(',', $ret);
    }
732605
public function getShowRowsHtml(array $fields = null)
    {
        $rows = '';
        $stub = $this->getStubContent('show.row.blade', $this->template);

        foreach ($this->getFieldsToDisplay($fields) as $field) {
            if ($field->isOnShowView) {
                $rows .= $this->getShowRowHtmlField($stub, $field) . PHP_EOL;
            }
        }

        return $rows;
    }
825571
protected function prepareFields($fields, $values) {
        $_fields = [];
        foreach ($fields as $field) {
            if ($field instanceof Query) { // sub-select SQL as field
                $field->setDialect($this->dialect);
                $field->setBindValues($values);
                $as = $field->getAlias();
                if ($as) {
                    $_fields [] = '(' . $field . ') AS ' . $this->sanitize('`' . $as . '`');
                }
            } else if ($field instanceof ImmutableValue) {
                $_fields [] = $field->__toString();
            } else { // this is simple field
                $_fields [] = $this->sanitize($field);
            }
        }
        if ($_fields) {
            return implode(',', $_fields);
        } else {
            return false;
        }
    }
950225
protected function generateFields()
	{
		$hiddenFields = '';

		$fields = array_reduce( $this->fields, function( $carry, $formField ) use ( &$hiddenFields ) {

			$stringLegend    = '<legend class="screen-reader-text"><span>%s</span></legend>';
			$stringFieldset  = '<fieldset%s>%s%s</fieldset>';
			$stringRendered  = '<tr class="glsr-field %s"><th scope="row">%s</th><td>%s</td></tr>';
			$outsideRendered = '</tbody></table>%s<table class="form-table"><tbody>';

			// set field value only when rendering because we need to check the default setting
			// against the database
			$field = $formField->setValue()->getField();

			$multi    = $field->multi === true;
			$label    = $field->generateLabel();
			$rendered = $field->render();

			// render hidden inputs outside the table
			if( $field->args['type'] === 'hidden' ) {
				$hiddenFields .= $rendered;
				return $carry;
			}

			$hiddenClass = $this->isFieldHidden( $formField ) ? 'hidden' : '';

			if( $multi ) {
				if( $depends = $formField->getDataDepends() ) {
					$depends = sprintf( ' data-depends=\'%s\'', json_encode( $depends ));
				}

				$legend = $label ? sprintf( $stringLegend, $label ) : '';
				$rendered = sprintf( $stringFieldset, $depends, $legend, $rendered );
			}

			$renderedField = $field->outside
				? sprintf( $outsideRendered, $rendered )
				: sprintf( $stringRendered, $hiddenClass, $label, $rendered );

			return $carry . $renderedField;
		});

		return sprintf( '<table class="form-table"><tbody>%s</tbody></table>%s', $fields, $hiddenFields );
	}
90676
protected function prepare_form_fields(array $fields) {

        $formdata = new stdclass();
        $key = 0;
        foreach ($fields as $field) {
            $formdata->{'dimensionid__idx_' . $key}             = $field->id;
            $formdata->{'description__idx_' . $key}             = $field->description;
            $formdata->{'description__idx_' . $key.'format'}    = $field->descriptionformat;
            $formdata->{'numoflevels__idx_' . $key}             = count($field->levels);
            $lev = 0;
            foreach ($field->levels as $level) {
                $formdata->{'levelid__idx_' . $key . '__idy_' . $lev} = $level->id;
                $formdata->{'grade__idx_' . $key . '__idy_' . $lev} = $level->grade;
                $formdata->{'definition__idx_' . $key . '__idy_' . $lev} = $level->definition;
                $formdata->{'definition__idx_' . $key . '__idy_' . $lev . 'format'} = $level->definitionformat;
                $lev++;
            }
            $key++;
        }
        return $formdata;
    }
444081
public function renderForm($form, $values=array())
    {
        $result = '';
        if (isset($form['tabs']))
        {
            $result .= $this->renderTabs($form['tabs']);
        }
        $wnd['caption'] = $form['caption'];
        $wnd['width'] = isset($form['width'])?$form['width']:'';
        $wnd['style'] = 'padding: 0px;';

        $form = new Form($form, $values);
        $wnd['body'] = $form->render();
        $result .= $this->window($wnd);
        return $result;
    }