Renders form field

@param \yii\db\ActiveRecord $model
@param \yii\widgets\ActiveForm $form
@param string $name
@param array $data
161098
public static function renderControlGroup($model, $form, $name, $data)
    {
        if (isset($data['model'])) {
            $model = $data['model'];
        }
        $field = $form->field($model, $name);
        if (isset($data['formMethod'])) {
            if (is_string($data['formMethod'])) {
                echo call_user_func_array([$field, $data['formMethod']], $data['arguments']);
            } else {
                echo call_user_func($data['formMethod'], $field, $data['arguments']);
            }
            return;
        }
        if (isset($data['options']['label'])) {
            $label = $data['options']['label'];
            unset($data['options']['label']);
        } else {
            $label = $model->getAttributeLabel($name);
        }
        echo $field
                ->label($label, ['class' => 'control-label'])
                ->error(['class' => 'help-block'])
                ->widget($data['widgetClass'], $data['options']);
        return;
    }
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);
    }
853610
protected function formField ($name, $def = null)
  {
    return Http::field ($this->request, $name, $def);
  }
852279
public function renderField()
    {
        list($name, $id) = $this->resolveNameID();

        TbArray::defaultValue('id', $id, $this->htmlOptions);
        TbArray::defaultValue('name', $name, $this->htmlOptions);

        if ($this->useHelperSelectBox) {
            $select = Yii::createComponent(
                CMap::mergeArray(
                    $this->helperOptions,
                    array(
                        'class' => 'yiiwheels.widgets.formhelpers.WhSelectBox',
                        'htmlOptions' => $this->htmlOptions,
                        'model' => $this->model,
                        'attribute' => $this->attribute,
                        'name' => $this->name,
                        'value' => $this->value,
                        'wrapperOptions' => array(
                            'class' => 'bfh-fonts',
                            'data-family' => $this->hasModel() ? $this->model->{$this->attribute} : $this->value,
                        )
                    )
                )
            );
            $select->init();
            $select->run();
        } else {
            $this->htmlOptions['data-family'] = $this->hasModel()
                ? $this->model->{$this->attribute}
                : $this->value;

            if ($this->hasModel()) {
                echo CHtml::activeDropDownList($this->model, $this->attribute, array(), $this->htmlOptions);
            } else {
                echo CHtml::dropDownList($name, $this->value, array(), $this->htmlOptions);
            }
        }
    }
1280946
public function block($name, array $data = [])
    {
        $view = new View();
        $view->type($this->type());
        $view->context($this->context());
        $view->set(array_merge($this->viewVars, $data));
        return $view->render($name);
    }
813095
protected function getModel($model_name, $id, FormModel $form)
    {
        /*
         * We need to grab the model from the config and select one entry for
         * that model from within the database.
         */
        $model = $this->findModel($model_name, $id);
        /*
         * Here we generate the form to update the model using the kregel/formmodel
         * package
         */
        $form = $form->using(config('kregel.formmodel.using.framework'))
                            ->withModel($model)
                            ->submitTo(route('warden::api.update-model', [$model_name, $model->id]));
        $form_info = $form->form([
            'method'  => 'post',
            'enctype' => 'multipart/form-data',
        ]);

        return view('warden::view-model')
                ->with('form', $form_info)
                ->with('model_name', $model_name)
                ->with('vue_components', $form->vue_components);
    }
54227
public function form($form_name=null, $data=null)
    {
        $form_name || $form_name = $this->getDefaultFormName();
        
        $token = $this->get($data);
        
        return '<input type="hidden" name="' . $form_name . '" value="'. $token . '" />';
    }
1266277
public function render($name, $data = array())
    {
        // Assign to double underscored variables to avoid conflict with view parameters
        $__file = $this->getFile($name);
        $__data = $data + $this->data;
        $__layout = $this->layout;

        // Render view
        extract($__data, EXTR_OVERWRITE);
        ob_start();
        try {
            require $__file;
        } catch (\Exception $e) {
            ob_end_clean();
            throw $e;
        }
        $content = ob_get_clean();

        // If layout is configured, render layout
        if ($__layout != $this->layout) {
            $layout = $this->layout;
            $this->layout = array();
            $__data[$layout['variable']] = $content;
            $content = $this->render($layout['name'], $__data);
        }

        return $content;
    }
1304806
protected function buildFormOptions($name, array $field, $data = null)
    {
        // Allow sub options structure (collection case)
        if (isset($field['options']['constraints'])) {
            $field['options']['options'] = $this->buildFormOptions('', $field['options']);
        }

        $constraints = array();
        foreach ($field['constraints'] as $constraint) {
            $constraints[] = $this->buildConstraint($constraint);
        }

        $field['options']['constraints'] = $constraints;

        if (null !== $data && isset($data[$name])) {
            $field['options']['data'] = $data[$name];
        }

        return $field['options'];
    }
750464
public function render($name, $data = null)
    {
        if (! isset($this->macros[$name])) {
            throw new BadMethodCallException("Method [$name] does not exist.");
        }

        return call_user_func($this->macros[$name], $data);
    }
455665
public function replaceFormField(FormMapper $formMapper, $name, $type = null, array $options = [], array $fieldDescriptionOptions = [])
    {
        $admin = $formMapper->getAdmin();

        /** @var array $fg */
        $fg = $admin->getFormGroups();

        /** @var array $tb */
        $tb = $admin->getFormTabs();

        $keys = $formMapper->keys();

        if ($formMapper->has($name)) {
            $group = '';
            $tab = '';

            foreach ($fg as $fg_key => $fg_item) {
                if (isset($fg_item['fields'][$name])) {
                    $group = $fg_key;
                }
            }

            foreach ($tb as $tb_key => $tb_item) {
                if (\in_array($group, $tb_item['groups'])) {
                    $tab = $tb_key;
                }
            }

            $admin->removeFormFieldDescription($name);
            $admin->removeFieldFromFormGroup($name);

            $formBuilder = $formMapper->getFormBuilder();

            $formBuilder->remove($name);
            $formBuilder->getForm()->remove($name);

            $formMapper->remove($name);

            if ($formMapper->hasOpenTab()) {
                $formMapper->end();
            }

            if ($formMapper->hasOpenTab()) {
                $formMapper->end();
            }

            $formMapper->tab($tab);
            $formMapper->with($group);

            $formMapper->add($name, $type, $options, $fieldDescriptionOptions);

            $formMapper->end();
            $formMapper->end();

            $formMapper->reorder($keys);

            $admin->setFormTabs($tb);
            $admin->setFormGroups($fg);
        }
    }
667179
public function createNamedFormBuilder($name, $model, $form = 'default', $context = [], $options=[])
    {
        $fb = $this->formFactory->createNamedBuilder($name, FormType::class, $model, $options);

        $this->populateFormBuilder($fb, $model, $form, $context);
        return $fb;
    }
222911
private static function validateAttributes($model, $name, &$attributes)
    {
        // Should be an array.
        if (!is_array($attributes)) {
            $attributes = [$attributes];
        }

        // Is empty, use the name of the table + name.
        if (empty($attributes)) {
            $attributes = [sprintf('%s.%s', $model->getTable(), $name)];
        }

        // Check each of the attribute values.
        // Convert any prepended with a curly to an expression.
        foreach ($attributes as &$value) {
            if (substr($value, 0, 1) === '#' || substr($value, 0, 1) === '{') {
                $value = new Expression(substr($value, 1));
            }
        }
    }
419487
public function actionUpdate($name)
    {
        $model = $this->getModel(Rule::SCENARIO_UPDATE);
        $rule  = $this->findRule($name);

        $model->setOldName($name);
        $model->setAttributes([
            'name'  => $rule->name,
            'class' => get_class($rule),
        ]);

        if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
            \Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }

        if ($model->load(\Yii::$app->request->post()) && $model->update()) {
            \Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Rule has been updated'));
            return $this->redirect(['index']);
        }

        return $this->render('update', [
            'model' => $model,
        ]);
    }
1021843
static function laraform($name) {
        $el = new ElementSwitchTwbs($name);
        $el->addClass('js-bootstrap-switch')
            ->setOffClass('danger')
            ->setOffLabel('Нет')
            ->setOnClass('success')
            ->setOnLabel('Да')
            ->setSizeSmall();

        return $el;
    }
1311643
protected function view($name, array $data = [])
    {
        $this->viewExistsOrFail($name);

        $this->data = array_merge($this->data, $data);

        $this->beforeViewRender();
        $view = $this->renderView($name);
        $this->afterViewRender();

        return $view;
    }
1048573
public function renderIfPjax($name = null, $data = null, $layout_callback = null) {
        if (is_array($name)) {
            list($data, $layout_callback, $name) = [$name, $data, null];
        }
        if (empty($data)) {
            $data = [];
        }
        if (!app('request')->isPjax() && is_callable($layout_callback)) {
            $data = array_merge($data, call_user_func($layout_callback));
        }
        return $this->show($name, $data);
    }