Prepare the widgets used by this action
Model $model
6989
protected function initWidgets($model)
    {
        $config = $model->getFieldConfig();
        $config->model = $model;
        $config->arrayName = class_basename($model);
        $config->context = 'update';

        $widget = $this->makeWidget('Backend\Widgets\Form', $config);
        $widget->bindToController();
        $this->formWidget = $widget;
    }
500150
def get_templates(self, action='index'):
        
        app = self.opts.app_label
        model_name = self.opts.model_name
        return [
            'wagtailmodeladmin/%s/%s/%s.html' % (app, model_name, action),
            'wagtailmodeladmin/%s/%s.html' % (app, action),
            'wagtailmodeladmin/%s.html' % (action,),
        ]
650946
@Override
    protected void defineWidgets() {

        setKeyPrefix(KEY_PREFIX);

        // initialize the cache object to use for the dialog
        CmsFlexController controller = (CmsFlexController)getJsp().getRequest().getAttribute(
            CmsFlexController.ATTRIBUTE_NAME);
        CmsFlexCache cache = controller.getCmsCache();

        setOffline(true);
        setOnline(true);
        setMode(MODE_ALL);

        // widgets to display
        if (cache.cacheOffline()) {
            addWidget(new CmsWidgetDialogParameter(this, "offline", PAGES[0], new CmsCheckboxWidget()));
        }
        addWidget(new CmsWidgetDialogParameter(this, "online", PAGES[0], new CmsCheckboxWidget()));
        addWidget(new CmsWidgetDialogParameter(this, "mode", PAGES[0], new CmsRadioSelectWidget(getModes())));
    }
1150429
public function prepareVars()
    {
        $this->populateTableWidget();
        $this->vars['table'] = $this->table;
        $this->vars['size'] = $this->size;
        $this->vars['rowSorting'] = $this->rowSorting;
    }
661392
def set_widgets(self):
        """"""
        existing_inasafe_field = self.parent.get_existing_keyword(
            'inasafe_fields')
        # Remove old container and parameter
        if self.parameter_container:
            self.kwExtraKeywordsGridLayout.removeWidget(
                self.parameter_container)
        if self.parameters:
            self.parameters = []

        # Iterate through all inasafe fields
        for inasafe_field in self.inasafe_fields_for_the_layer():
            # Option for Not Available
            option_list = [no_field]
            for field in self.parent.layer.fields():
                # Check the field type
                if isinstance(inasafe_field['type'], list):
                    if field.type() in inasafe_field['type']:
                        field_name = field.name()
                        option_list.append('%s' % field_name)
                else:
                    if field.type() == inasafe_field['type']:
                        field_name = field.name()
                        option_list.append('%s' % field_name)

            # If there is no option, pass
            if option_list == [no_field]:
                continue

            # Create SelectParameter
            select_parameter = SelectParameter()
            select_parameter.guid = inasafe_field['key']
            select_parameter.name = inasafe_field['name']
            select_parameter.is_required = False
            select_parameter.description = inasafe_field['description']
            select_parameter.help_text = inasafe_field['help_text']
            select_parameter.element_type = str
            select_parameter.options_list = option_list
            select_parameter.value = no_field
            # Check if there is already value in the metadata.
            if existing_inasafe_field:
                existing_value = existing_inasafe_field.get(
                    inasafe_field['key'])
                if existing_value:
                    if existing_value in select_parameter.options_list:
                        select_parameter.value = existing_value

            self.parameters.append(select_parameter)

        # Create the parameter container and add to the wizard.
        self.parameter_container = ParameterContainer(self.parameters)
        self.parameter_container.setup_ui()
        self.kwExtraKeywordsGridLayout.addWidget(self.parameter_container)

        if not self.parameters:
            no_field_message = tr(
                'There is no available field that has match type for the '
                'InaSAFE fields. You can click next.')
            self.lblInaSAFEFields.setText(no_field_message)
824293
public function init()
    {
        $this->fillFromConfig([
            'buttons',
            'search',
        ]);

        /*
         * Prepare the search widget (optional)
         */
        if (isset($this->search)) {

            if (is_string($this->search)) {
                $searchConfig = $this->makeConfig(['partial' => $this->search]);
            }
            else {
                $searchConfig = $this->makeConfig($this->search);
            }

            $searchConfig->alias = $this->alias . 'Search';
            $this->searchWidget = $this->makeWidget('Backend\Widgets\Search', $searchConfig);
            $this->searchWidget->bindToController();
        }
    }
351121
function() {
      return _.map(this.models, function(model) {
        // Pull out component models
        if (model.type === 'Widget' && model.model) {
          return model.model;
        } else {
          return model;
        }
      });
    }
213315
protected function initConfigByBehavior()
    {
        if ($this->hasModel() && $this->model->hasProperty('dateTimeWidget')) {
            /** @var ModifyTimestampBehavior $modifyTimestampBehavior */
            $modifyTimestampBehavior = $this->model;
            $displayData = $modifyTimestampBehavior->getDisplayFormat($this->attribute, true);
            $saveData = $modifyTimestampBehavior->getSaveFormat($this->attribute, true);
            $this->type = $displayData['type'];
            $this->displayFormat = $displayData['format'];
            $this->saveFormat = $saveData['format'];
            $this->displayTimezone = $modifyTimestampBehavior->displayTimeZone;
            $this->saveTimezone = $modifyTimestampBehavior->saveTimeZone;
        }
    }
1364282
def set_widgets(self):
        """"""
        self.clear()
        self.layer_mode = self.parent.step_kw_layermode.selected_layermode()
        self.layer_purpose = self.parent.step_kw_purpose.selected_purpose()
        self.set_current_state()

        # Set the step description
        self.set_wizard_step_description()

        # Set the left panel
        self.setup_left_panel()

        # Set the right panel, for the beginning show the viewer
        self.show_current_state()
84303
private function prepareWidgetAttributes(ModelInterface $model, PropertyInterface $property)
    {
        $environment = $this->getEnvironment();
        $defName     = $environment->getDataDefinition()->getName();

        $propExtra = $property->getExtra();

        $value = $this->valueToWidget($model, $property);

        $propExtra['required'] = ('' === $value) && !empty($propExtra['mandatory']);

        $widgetConfig = [
            'inputType' => $property->getWidgetType(),
            'label'     => [
                $property->getLabel(),
                $property->getDescription()
            ],
            'options'   => $this->getOptionsForWidget($property, $model),
            'eval'      => $propExtra,
            // 'foreignKey' => null
        ];

        if (isset($propExtra['reference'])) {
            $widgetConfig['reference'] = $propExtra['reference'];
        }

        $event = new GetAttributesFromDcaEvent(
            $widgetConfig,
            $property->getName(),
            $value,
            $property->getName(),
            $defName,
            new DcCompat($environment, $model, $property->getName())
        );

        $environment->getEventDispatcher()->dispatch(ContaoEvents::WIDGET_GET_ATTRIBUTES_FROM_DCA, $event);
        $prepareAttributes = $event->getResult();

        if (('checkbox' === $widgetConfig['inputType'])
            && $widgetConfig['eval']['submitOnChange']
            && isset($GLOBALS['TL_DCA'][$defName]['subpalettes'])
            && \is_array($GLOBALS['TL_DCA'][$defName]['subpalettes'])
            && \array_key_exists($property->getName(), $GLOBALS['TL_DCA'][$defName]['subpalettes'])
        ) {
            // We have to override the onclick, do not append to it as Contao adds it's own code here in
            // Widget::getAttributesFromDca() which kills our sub palette handling!
            $prepareAttributes['onclick'] = "Backend.autoSubmit('" . $defName . "');";
        }

        return $prepareAttributes;
    }
837941
function () {
            this.$BindableWidget.initWidget.call(this);

            var bindings = this._cfg.bind;
            var isBound = false;

            if (bindings.visible) {
                var visible = this._transform(bindings.visible.transform, bindings.visible.inside[bindings.visible.to], "toWidget");
                if (visible === true) {
                    this.show();
                }
                isBound = true;
            }
            if (!isBound) {
                this.$logWarn(this.BINDING_NEEDED, [this.$class, "visible"]);
            }
        }
528419
@Override
    protected void defineWidgets() {

        // initialize the project object to use for the dialog
        initProjectObject();

        setKeyPrefix(KEY_PREFIX);

        // widgets to display
        if (isNewProject()) {
            addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsInputWidget()));
        } else {
            addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsDisplayWidget()));
        }
        addWidget(new CmsWidgetDialogParameter(m_project, "description", "", PAGES[0], new CmsTextareaWidget(), 0, 1));
        addWidget(new CmsWidgetDialogParameter(this, "managerGroup", PAGES[0], new CmsGroupWidget(null, null)));
        addWidget(new CmsWidgetDialogParameter(this, "userGroup", PAGES[0], new CmsGroupWidget(null, null)));
        if (isNewProject()) {
            int ous = 1;
            try {
                ous = OpenCms.getRoleManager().getOrgUnitsForRole(getCms(), CmsRole.PROJECT_MANAGER, true).size();
            } catch (CmsException e) {
                // should never happen
            }
            if (ous < 2) {
                addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget()));
            } else {
                addWidget(
                    new CmsWidgetDialogParameter(
                        this,
                        "oufqn",
                        PAGES[0],
                        new CmsOrgUnitWidget(CmsRole.PROJECT_MANAGER)));
            }
        } else {
            addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget()));
        }
        addWidget(new CmsWidgetDialogParameter(m_project, "deleteAfterPublishing", PAGES[0], new CmsCheckboxWidget()));
        addWidget(
            new CmsWidgetDialogParameter(this, "resources", PAGES[0], new CmsVfsFileWidget(false, "", false, false)));
    }
1261325
@Override
    protected void prepareActions() throws QTasteTestFailException {
        mIndex = Integer.parseInt(mData[0].toString());
        if (component instanceof JComboBox) {
            JComboBox combo = (JComboBox) component;
            if (combo.getItemCount() < mIndex) {
                throw new QTasteTestFailException("Specified index is out of bounds");
            }
        } else if (component instanceof JList) {
            JList list = (JList) component;
            if (list.getModel().getSize() < mIndex) {
                throw new QTasteTestFailException("Specified index is out of bounds");
            }
        } else {
            throw new QTasteTestFailException("Unsupported component");
        }
    }
132502
public function prepareVars()
    {
        $this->vars['model'] = $this->model;
        $this->vars['items'] = $this->model->menus;

        $this->vars['emptyItem'] = [
            'label' => Lang::get('rainlab.builder::lang.menu.new_menu_item'),
            'icon' => 'icon-life-ring',
            'code' => 'newitemcode',
            'url' => '/'
        ];

        $this->vars['emptySubItem'] = [
            'label' => Lang::get('rainlab.builder::lang.menu.new_menu_item'),
            'icon' => 'icon-sitemap',
            'code' => 'newitemcode',
            'url' => '/'
        ];
    }
1318773
public function initialize()
    {
        /**
         * Attaches event fired before view render
         * It allows to use $this->view->partial inside of action method before action view is being rendered
         */
        $this->eventsManager->attach('view:beforeRenderView', function($event, $view, $engineViewPath) {
            if ($view instanceof View) {
                $view->setControllerViewPath($this->router->getControllerName());
            }
        });
    }
476199
protected function _saveAppWidgets(): void
    {
        $widgets = $this->_getAppWidgets();

        $found = [];
        foreach ($widgets as $widget) {
            $found[] = $widget['name'];

            // skip adding existing app widgets
            if ($this->exists(['AppWidgets.name' => $widget['name']])) {
                continue;
            }

            $entity = $this->newEntity();
            $entity = $this->patchEntity($entity, $widget);
            $this->save($entity);
        }

        // soft delete non-existing app widgets
        $this->trashAll(! empty($found) ? ['AppWidgets.name NOT IN' => $found] : []);
    }
574352
def ready(self):
        """"""
        models_config.auto_load_configs()

        self.auto_load_app_modules(['layouts', 'signals'])

        app_menu.auto_load_model_menu()

        auto_register_search_models()
        tabs.auto_generate_missing_tabs()