Prepare form object for rendering with a view

@return array
501488
public function prepareForView()
    {
        $formData = [];
        foreach ($this->fieldsets as $fieldset) {
            $formData = array_merge($formData, $fieldset->prepareForView());
        }
        return $formData;
    }
462454
protected function _prepareForm()
    {
        $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
        $model = $this->_coreRegistry->registry('row_data');
        $form = $this->_formFactory->create(
            ['data' => [
                'id' => 'edit_form',
                'enctype' => 'multipart/form-data',
                'action' => $this->getData('action'),
                'method' => 'post'
            ]
            ]
        );

        $form->setHtmlIdPrefix('worldnettps_subscription_');
        if ($model->getEntityId()) {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __(''), 'class' => 'fieldset-wide']
            );
            $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']);
        } else {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __(''), 'class' => 'fieldset-wide']
            );
        }

        if ($model->getEntityId()) {
            $fieldset->addField(
                'merchant_ref2',
                'text',
                [
                    'name' => 'merchant_ref2',
                    'label' => __('Merchant Ref'),
                    'id' => 'merchant_ref2',
                    'title' => __('Merchant Ref'),
                    'class' => 'required-entry',
                    'required' => true,
                    'disabled' => true
                ]
            );
            $fieldset->addField(
                'merchant_ref',
                'hidden',
                [
                    'name' => 'merchant_ref',
                    'label' => __(''),
                    'id' => 'merchant_ref',
                    'title' => __(''),
                    'class' => 'required-entry',
                    'required' => true,
                ]
            );
        } else {
            $fieldset->addField(
                'merchant_ref',
                'text',
                [
                    'name' => 'merchant_ref',
                    'label' => __('Merchant Ref'),
                    'id' => 'merchant_ref',
                    'title' => __('Merchant Ref'),
                    'class' => 'required-entry',
                    'required' => true,
                ]
            );
        }

        $fieldset->addField(
            'name',
            'text',
            [
                'name' => 'name',
                'label' => __('Name'),
                'id' => 'name',
                'title' => __('Name'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        $fieldset->addField(
            'description',
            'text',
            [
                'name' => 'description',
                'label' => __('Description'),
                'id' => 'description',
                'title' => __('Description'),
                'class' => '',
                'required' => false,
            ]
        );

        $fieldset->addField(
            'type',
            'select',
            [
                'name' => 'type',
                'label' => __('Type'),
                'id' => 'type',
                'title' => __('Type'),
                'values' => $this->_options->getType(),
                'class' => '',
                'onchange' => 'WorldnetTPSSubscriptionType()'
            ]
        );

        $fieldset->addField(
            'period_type',
            'select',
            [
                'name' => 'period_type',
                'label' => __('Period Type'),
                'id' => 'period_type',
                'title' => __('Period Type'),
                'values' => $this->_options->getPeriodType(),
                'class' => '',
                'disabled' => $model->getEntityId()?true:false
            ]
        );

        $fieldset->addField(
            'period_count',
            'select',
            [
                'name' => 'period_count',
                'label' => __('Period Count'),
                'id' => 'period_count',
                'title' => __('Period Count'),
                'values' => $this->_options->getPeriodCount(),
                'class' => '',
                'onchange' => 'WorldnetTPSSubscriptionPeriodCount()'
            ]
        );

        $fieldset->addField(
            'period_length',
            'text',
            [
                'name' => 'period_length',
                'label' => __(''),
                'id' => 'period_length',
                'title' => __(''),
                'required' => false
            ]
        );

        $fieldset->addField(
            'recurring_price',
            'text',
            [
                'name' => 'recurring_price',
                'label' => __('Recurring Price'),
                'id' => 'recurring_price',
                'title' => __('Recurring Price'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        $fieldset->addField(
            'setup_price',
            'text',
            [
                'name' => 'setup_price',
                'label' => __('Setup Price'),
                'id' => 'setup_price',
                'title' => __('Setup Price'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        if ($model->getEntityId()) {
            $fieldset->addField(
                'currency2',
                'select',
                [
                    'name' => 'currency2',
                    'label' => __('Currency'),
                    'id' => 'currency2',
                    'title' => __('Currency'),
                    'class' => 'required-entry',
                    'required' => true,
                    'values' => $this->_options->getCurrency(),
                    'disabled' => true
                ]
            );
            $fieldset->addField(
                'currency',
                'hidden',
                [
                    'name' => 'currency',
                    'label' => __(''),
                    'id' => 'currency',
                    'title' => __(''),
                    'class' => 'required-entry',
                    'required' => true,
                ]
            );
        } else {
            $fieldset->addField(
                'currency',
                'select',
                [
                    'name' => 'currency',
                    'label' => __('Currency'),
                    'id' => 'currency',
                    'title' => __('Currency'),
                    'class' => 'required-entry',
                    'required' => true,
                    'values' => $this->_options->getCurrency(),
                ]
            );
        }

        $fieldset->addField(
            'on_update',
            'select',
            [
                'name' => 'on_update',
                'label' => __('On Update'),
                'id' => 'on_update',
                'title' => __('On Update'),
                'values' => $this->_options->getOnUpdate(),
                'class' => '',
            ]
        );

        $fieldset->addField(
            'on_delete',
            'select',
            [
                'name' => 'on_delete',
                'label' => __('On Delete'),
                'id' => 'on_delete',
                'title' => __('On Delete'),
                'values' => $this->_options->getOnDelete(),
                'class' => '',
            ]
        );

        $form->setValues($model->getData());
        $form->setUseContainer(true);
        $this->setForm($form);

        return parent::_prepareForm();
    }
201055
public function renderConfigurationForm()
    {
        $record = $this->getConfigurationRecord();
        if ($record->exists()) {
            call_user_func(
                function ($_vars) {
                    extract($_vars);
                    unset($_vars);
                    require_once $_file;
                },
                [
                    '_file' => $record->getFile(),
                    'app' => $this->app,
                    'geolocator' => $this->geolocator,
                    'controller' => $this,
                    'form' => $this->app->make('helper/form'),
                ]
            );
        }
    }
894350
public function render()
    {
        if (! $this->display) {
            return;
        }

        $this->runBeforeRender();
        $this->checkRequired();
        $this->translate();

        $attributes = $this->getModifyAttributes();
        $this->attributes['id'] = $this->getId();

        if ($this->hasError()) {
            if (! isset($attributes['class']) || is_null($attributes['class'])) {
                $attributes['class'] = ' is-invalid';
            } else {
                $attributes['class'] .= ' is-invalid';
            }
        }

        return view($this->view, array_merge($this->getAttributes(), [
            'attributes' => $attributes,
            'id'         => $this->getId(),
            'old'        => $this->getOldValue(),
            'slug'       => $this->getSlug(),
            'oldName'    => $this->getOldName(),
            'typeForm'   => $this->typeForm ?? $this->vertical()->typeForm,
        ]))
            ->withErrors(session()->get('errors', app(ViewErrorBag::class)));
    }
232831
public function Form()
    {
        $form = UserForm::create($this, 'Form_' . $this->ID);
        /** @skipUpgrade */
        $form->setFormAction(Controller::join_links($this->Link(), 'Form'));
        $this->generateConditionalJavascript();
        return $form;
    }
253759
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

        /** @var \Mirasvit\Blog\Model\Post $post */
        $post = $this->registry->registry('current_model');

        $fieldset = $form->addFieldset('image_fieldset', [
            'class'  => 'blog__post-fieldset',
            'legend' => __('Featured Image'),
        ]);

        $fieldset->addField('featured_image', 'image', [
            'required' => false,
            'name'     => 'featured_image',
            'value'    => $post->getFeaturedImageUrl(),
        ]);

        $fieldset->addField('featured_alt', 'text', [
            'required' => false,
            'label'   => __('Alt'),
            'name'     => 'post[featured_alt]',
            'value'    => $post->getFeaturedAlt(),
        ]);

        $fieldset->addField('featured_show_on_home', 'checkbox', [
            'label'   => __('Is show on Blog Home page'),
            'name'    => 'post[featured_show_on_home]',
            'value'   => 1,
            'checked' => $post->getFeaturedShowOnHome(),
        ]);

        return parent::_prepareForm();
    }
986361
public function RenderTemplate () {
		$formViewScript = $this->form->GetViewScript();
		return $this->Render(
			static::$formsDir,
			is_bool($formViewScript) ? $this->form->GetId() : $formViewScript
		);
	}
929378
public function render()
	{
		switch ($this->getContext()) {
			case BaseField::CONTEXT_LIST:
				$values = [];
				foreach ($this->getValue() as $item) {
					$values[] = $item->{$this->getDisplayField()};
				}

				return implode(', ', $values);

				break;
			case BaseField::CONTEXT_FORM:

				$baseModel  = $this->getAdmin()->getModel();
				$baseModel  = new $baseModel;
				$primaryKey = $baseModel->getKeyName();

				$relatedModel = $baseModel->{$this->getName()}()->getRelated();
				$relatedModel = get_class($relatedModel);

				$items = [];
				foreach ($relatedModel::all() as $item) {
					$items[$item->{$primaryKey}] = $item->{$this->getDisplayField()};
				}

				$id = $this->getAdmin()->getFormBuilder()->getIdentifier();

				$values = [];
				foreach ($relatedModel::where(Str::singular($baseModel->getTable()) . '_id', $id)->get() as $item) {
					$values[] = (string) $item->{$primaryKey};
				}

				return View::make('krafthaus/bauhaus::models.fields._has_many')
					->with('field',  $this)
					->with('items',  $items)
					->with('values', $values);

				break;
		}
	}
1084476
public function prepareVars()
    {
        $this->vars['field'] = $this->formField;
        $this->vars['editorLang'] = $this->getValidEditorLang();
        $this->vars['fullPage'] = $this->fullPage;
        $this->vars['stretch'] = $this->formField->stretch;
        $this->vars['size'] = $this->formField->size;
        $this->vars['readOnly'] = $this->readOnly;
        $this->vars['name'] = $this->getFieldName();
        $this->vars['value'] = $this->getLoadValue();
        $this->vars['toolbarButtons'] = $this->evalToolbarButtons();

        $this->vars['globalToolbarButtons'] = EditorSetting::getConfigured('html_toolbar_buttons');
        $this->vars['allowEmptyTags'] = EditorSetting::getConfigured('html_allow_empty_tags');
        $this->vars['allowTags'] = EditorSetting::getConfigured('html_allow_tags');
        $this->vars['noWrapTags'] = EditorSetting::getConfigured('html_no_wrap_tags');
        $this->vars['removeTags'] = EditorSetting::getConfigured('html_remove_tags');
        $this->vars['lineBreakerTags'] = EditorSetting::getConfigured('html_line_breaker_tags');

        $this->vars['imageStyles'] = EditorSetting::getConfiguredStyles('html_style_image');
        $this->vars['linkStyles'] = EditorSetting::getConfiguredStyles('html_style_link');
        $this->vars['paragraphStyles'] = EditorSetting::getConfiguredStyles('html_style_paragraph');
        $this->vars['tableStyles'] = EditorSetting::getConfiguredStyles('html_style_table');
        $this->vars['tableCellStyles'] = EditorSetting::getConfiguredStyles('html_style_table_cell');
    }
113813
private function beforeForm() {
    // Add Bootstrap CSS if is enabled
    $form_class = "";
    if ( $this -> isUsingBootstrap() ) {
      echo $this -> constants -> getBootstrapCSS();
      if( $this -> bootstrap_form_orientation == "horizontal" ){
        $form_class = "form-horizontal";
      }else if( $this -> bootstrap_form_orientation = "inline" ){
        $form_class = "form-inline";
      }
    }

    // Render form header
    echo "<form method='" . $this -> form_method . "' action='" . $this -> form_action . "' class='" . $form_class . "'>";
  }
1191128
public function _prepareForm()
    {
        $model = $this->_coreRegistry->registry('current_ddg_rule');
        $form = $this->_formFactory->create();
        $form->setHtmlIdPrefix('rule_');

        $fieldset = $form->addFieldset(
            'base_fieldset',
            ['legend' => __('Exclusion Rule Conditions')]
        );

        $fieldset->addField('combination', 'select', [
            'label' => __('Conditions Combination Match'),
            'title' => __('Conditions Combination Match'),
            'name' => 'combination',
            'required' => true,
            'options' => [
                '1' => __('ALL'),
                '2' => __('ANY'),
            ],
            'after_element_html' => '<small>Choose ANY if using multi line conditions 
for same attribute. If multi line conditions for same attribute is used and ALL is chosen 
then multiple lines for same attribute will be ignored.</small>',
        ]);

        $field = $fieldset->addField('condition', 'select', [
            'name' => 'condition',
            'label' => __('Condition'),
            'title' => __('Condition'),
            'required' => true,
            'options' => $this->options->toOptionArray(),
        ]);
        $renderer = $this->getLayout()
            ->createBlock(\Dotdigitalgroup\Email\Block\Adminhtml\Config\Rules\Customdatafields::class);
        $field->setRenderer($renderer);

        $form->setValues($model->getData());
        $this->setForm($form);

        return parent::_prepareForm();
    }
662057
public function prepareTemplateParameters(View $view)
    {
        $data = $view->getData();

        if ($data instanceof FormInterface) {
            $data = [$view->getTemplateVar() => $data->getData(), 'form' => $data];
        } elseif (empty($data) || !is_array($data) || is_numeric((key($data)))) {
            $data = [$view->getTemplateVar() => $data];
        }

        if (isset($data['form']) && $data['form'] instanceof FormInterface) {
            $data['form'] = $data['form']->createView();
        }

        $templateData = $view->getTemplateData();
        if (is_callable($templateData)) {
            $templateData = call_user_func($templateData, $this, $view);
        }

        return array_merge($data, $templateData);
    }
138259
public function get_search_form()
    {
        $data = [];

        if (\function_exists('random_int')) {
            try {
                $data['searchform_id'] = 'search_' . \random_int(1000, 8000);
            } catch (\Exception $e) {
                // Fail silently.
            }
        }

        if (! isset($data['searchform_id'])) {
            $data = [
                'searchform_id' => \uniqid('search_', true),
            ];
        }

        \ob_start();
        View::partial('searchform', $data);
        $form = \ob_get_clean();

        return $form;
    }
1327357
public function prepareVars()
    {
        $this->relationModel = $this->getLoadValue();

        if ($this->formField->disabled) {
            $this->previewMode = true;
        }

        $this->vars['value'] = $this->getKeyValue();
        $this->vars['field'] = $this->formField;
        $this->vars['nameValue'] = $this->getNameValue();
        $this->vars['descriptionValue'] = $this->getDescriptionValue();
        $this->vars['listWidget'] = $this->listWidget;
        $this->vars['searchWidget'] = $this->searchWidget;
        $this->vars['title'] = $this->title;
        $this->vars['prompt'] = str_replace('%s', '<i class="icon-th-list"></i>', e(trans($this->prompt)));
    }
32538
public function render()
    {
        if ($this->html instanceof \Closure) {
            $this->html = $this->html->call($this->form->model(), $this->form);
        }

        if ($this->plain) {
            return $this->html;
        }

        $viewClass = $this->getViewElementClasses();

        return <<<EOT
<div class="form-group">
    <label  class="{$viewClass['label']} control-label">{$this->label}</label>
    <div class="{$viewClass['field']}">
        {$this->html}
    </div>
</div>
EOT;
    }
271967
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

        /** @var \Mirasvit\Blog\Model\Category $category */
        $category = $this->registry->registry('current_model');

        $fieldset = $form->addFieldset('edit_fieldset', [
            'legend' => __('Search Engine Optimization')
        ]);

        $fieldset->addField('url_key', 'text', [
            'label' => __('URL Key'),
            'name'  => 'url_key',
            'value' => $category->getUrlKey(),
        ]);

        $fieldset->addField('meta_title', 'text', [
            'label' => __('Meta Title'),
            'name'  => 'meta_title',
            'value' => $category->getMetaTitle(),
        ]);

        $fieldset->addField('meta_description', 'textarea', [
            'label' => __('Meta Description'),
            'name'  => 'meta_description',
            'value' => $category->getMetaDescription(),
        ]);

        $fieldset->addField('meta_keywords', 'textarea', [
            'label' => __('Meta Keywords'),
            'name'  => 'meta_keywords',
            'value' => $category->getMetaKeywords(),
        ]);

        return parent::_prepareForm();
    }
1248010
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

        /** @var \Mirasvit\Blog\Model\Category $category */
        $category = $this->registry->registry('current_model');

        $fieldset = $form->addFieldset('edit_fieldset', [
            'legend' => __('General Information')
        ]);

        if ($category->getId()) {
            $fieldset->addField('entity_id', 'hidden', [
                'name'  => 'entity_id',
                'value' => $category->getId(),
            ]);
        }

        $fieldset->addField('name', 'text', [
            'label'    => __('Title'),
            'name'     => 'name',
            'value'    => $category->getName(),
            'required' => true,
        ]);

        if (!$this->isHideParent($category)) {
            $categories = $this->categoryCollectionFactory->create()
                ->addAttributeToSelect('name')
                ->toOptionArray();

            $fieldset->addField('parent_id', 'radios', [
                'label'    => __('Parent Category'),
                'name'     => 'parent_id',
                'value'    => $category->getParentId() ? $category->getParentId() : 1,
                'values'   => $categories,
                'required' => true,
            ]);
        }

        $fieldset->addField('status', 'select', [
            'label'  => __('Status'),
            'name'   => 'status',
            'value'  => $category->getStatus(),
            'values' => ['0' => __('Disabled'), '1' => __('Enabled')]
        ]);

        $fieldset->addField('sort_order', 'text', [
            'label'  => __('Order'),
            'name'   => 'sort_order',
            'value'  => $category->getSortOrder(),
        ]);

        return parent::_prepareForm();
    }