Gets the form to connect a branch to a template.
767066
@RequestMapping(value = "branches/{branchId}/template/connect", method = RequestMethod.GET)
    public Form connectTemplateInstance(@PathVariable ID branchId) {
        // Loads the branch
        Branch branch = structureService.getBranch(branchId);
        // List of templates
        Collection<LoadedBranchTemplateDefinition> templateDefinitions = branchTemplateService.getTemplateDefinitions(branch.getProject());
        // List of sync form per template
        return Form.create()
                .with(
                        ServiceConfigurator.of("connectionRequest")
                                .label("Template")
                                .help("Template to connect to")
                                .sources(
                                        templateDefinitions.stream()
                                                .map(lbtd -> new ServiceConfigurationSource(
                                                        lbtd.getBranch().getId().toString(),
                                                        lbtd.getBranch().getName(),
                                                        lbtd.getForm()
                                                ))
                                                .collect(Collectors.toList())
                                )
                );
    }
104767
def get_form(self, key, form_class=None):
        
        if form_class is None:
            form_class = self.get_form_class(key)
        return form_class(**self.get_form_kwargs(key))
68248
def get_gradebook_form(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinAdminSession.get_bin_form_for_update_template
        # This method might be a bit sketchy. Time will tell.
        if isinstance(args[-1], list) or 'gradebook_record_types' in kwargs:
            return self.get_gradebook_form_for_create(*args, **kwargs)
        else:
            return self.get_gradebook_form_for_update(*args, **kwargs)
1330339
def _get_form(self, config_name, only_required=False):
        """"""
        if getattr(self, config_name, None):
            return import_object_by_string(getattr(self, config_name))

        def use_field(field):
            if not only_required:
                return True
            return field.default == NOT_PROVIDED

        return modelform_factory(self.model, fields=[f.name for f in self.model.get_fields() if use_field(f)])
259288
def get_form(self, form_class):
        """"""
        if not hasattr(self, '_form'):
            kwargs = self.get_form_kwargs()
            self._form = form_class(instance=self.object, **kwargs)
        return self._form
1047497
def get_formset(self, form, name):
        
        kwargs = self.get_kwargs(form, name)
        formset_class = self.get_formset_class(form, name)
        formset = formset_class(
            form.data if form.is_bound else None,
            form.files if form.is_bound else None,
            **kwargs)
        return formset
1047883
def clean_form_template(self):
        
        form_template = self.cleaned_data.get('form_template', '')
        if form_template:
            try:
                get_template(form_template)
            except TemplateDoesNotExist:
                msg = _('Selected Form Template does not exist.')
                raise forms.ValidationError(msg)
        return form_template
1293141
def get_formset(self, request, obj=None, **kwargs):
        
        data = super().get_formset(request, obj, **kwargs)
        if obj:
            data.form.base_fields['user'].initial = request.user.id
        return data
951459
protected function getFormGenerator()
    {
        if (null === $this->formGenerator) {
            $this->formGenerator = new FormGenerator($this->getContainer()->get('filesystem'),  __DIR__.'/../Resources/skeletons/form');
        }

        return $this->formGenerator;
    }
193228
@RequestMapping(value = "configurations/create", method = RequestMethod.GET)
    public Form getConfigurationForm() {
        return StashConfiguration.Companion.form();
    }
975261
def batch_connect_config(template = nil)
      if template
        @batch_connect_config.fetch(template.to_sym, {}).to_h.symbolize_keys.merge(template: template.to_sym)
      else
        @batch_connect_config
      end
    end
821225
protected function buildForm()
    {
        if ($this->form) {
            return;
        }

        // append parent object if any
        // todo : clean the way the Admin class can retrieve set the object
        if ($this->isChild() && $this->getParentAssociationMapping()) {
            $parent = $this->getParent()->getObject($this->request->get($this->getParent()->getIdParameter()));

            $propertyAccessor = $this->getConfigurationPool()->getPropertyAccessor();
            $propertyPath = new PropertyPath($this->getParentAssociationMapping());

            $object = $this->getSubject();

            $value = $propertyAccessor->getValue($object, $propertyPath);

            if (\is_array($value) || ($value instanceof \Traversable && $value instanceof \ArrayAccess)) {
                $value[] = $parent;
                $propertyAccessor->setValue($object, $propertyPath, $value);
            } else {
                $propertyAccessor->setValue($object, $propertyPath, $parent);
            }
        }

        $formBuilder = $this->getFormBuilder();
        $formBuilder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
            $this->preValidate($event->getData());
        }, 100);

        $this->form = $formBuilder->getForm();
    }
483818
def get_form(self, form_class):
        """"""
        if not hasattr(self, '_form'):
            kwargs = self.get_form_kwargs()
            self._form = form_class(**kwargs)
        return self._form
736630
def get_form(self, form, name):
        
        kwargs = self.get_kwargs(form, name)
        form_class = self.get_form_class(form, name)
        composite_form = form_class(
            data=form.data if form.is_bound else None,
            files=form.files if form.is_bound else None,
            **kwargs)
        return composite_form
728461
public function getFormTemplate()
    {
        if (null === $this->formTemplate) {
            $template = rtrim($this->getTemplatePrefix(), '/') . '/' . $this->getFormSuffix();
            $this->setFormTemplate($template);
        }

        return $this->formTemplate;
    }
579667
protected function execUpdateForm()
    {
        // form translations
        $this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE));
        // get record
        $this->templateParameters['record'] = $this->getByPrimaryKey($this->primaryKeyValue);
        // render template
        $this->renderTemplate(sprintf('%s/%s/save-form', AREA, $this->name));
    }
134893
@RequestMapping(value = "branches/{branchId}/template/instance", method = RequestMethod.GET)
    public TemplateInstance getTemplateInstance(@PathVariable ID branchId) {
        return branchTemplateService.getTemplateInstance(branchId)
                .orElseThrow(() -> new BranchNotTemplateInstanceException(branchId));
    }