Build a form data dict from the given form.

        Args:
            soup (obj): The BeautifulSoup form.

        Returns:
            obj: The form data (key/value).
962025
def __get_form_data(self, soup):
        

        elements = self.__get_valid_form_data_elements(soup)
        form_data = self.__get_default_form_data_input(elements)
        callback = self.options.callbacks.form_before_autofill
        action = callback(self.queue_item, elements, form_data)

        if action == CrawlerActions.DO_AUTOFILL_FORM:
            self.__autofill_form_data(form_data, elements)

        return form_data
898052
def to_obj(cls, obj_data=None, *fields, **field_map):
    '''  '''
    obj_dict = obj_data.__dict__ if hasattr(obj_data, '__dict__') else obj_data
    if not fields:
        fields = obj_dict.keys()
    obj = cls()
    update_obj(obj_dict, obj, *fields, **field_map)
    return obj
400504
def get_forms(self):
        
        forms = {}
        objects = self.get_objects()
        initial = self.get_initial()
        form_kwargs = self.get_form_kwargs()
        for key, form_class in six.iteritems(self.form_classes):
            forms[key] = form_class(instance=objects[key], initial=initial[key], **form_kwargs[key])
        return forms
541681
def get_context_data(self, **kwargs):
        
        context = {}
        if 'forms' not in kwargs:
            context['forms'] = self.get_forms()
        else:
            context['forms'] = kwargs['forms']
        return context
350497
def update_object(self, form, obj):
        
        field_name = form.cleaned_data['name']
        value = form.cleaned_data['value']
        setattr(obj, field_name, value)
        save_kwargs = {}
        if CAN_UPDATE_FIELDS:
            save_kwargs['update_fields'] = [field_name]
        obj.save(**save_kwargs)

        data = json.dumps({
            'status': 'success',
        })
        return HttpResponse(data, content_type="application/json")
767167
def element_attribs_to_dict(self, element):
        
        return {self.ns+':'+key: val for (key, val) in element.attrib.items()
                if key != add_ns('id')}
1281809
def soup(self):
        '''
            
        '''
        dom = BeautifulSoup('<!DOCTYPE html>')

        # BeautifulSoup behaves differently if lxml is installed or not,
        # and will create a basic HTML structure if lxml is installed.
        if len(dom) > 1:
            list(dom.children)[1].replaceWith('')  # Removing default content

        soup = Element.soup(self)
        dom.append(soup)

        for plugin in self.plugins(deduplicate=True):
            dom = plugin(dom)

        return dom
894007
def get(self, request, *args, **kwargs):
        
        #noinspection PyAttributeOutsideInit
        self.object_list    = self.get_queryset()
        context             = self.get_context_data(force_search=True)

        if self.form_class:
            context.update({'form': self.get_form()})

        if 'q' in request.GET or 'p' in request.GET:
            return render(
                request,
                '{0}/results.html'.format(self.template_dir),
                context
            )
        else:
            return render_modal_workflow(
                request,
                '{0}/chooser.html'.format(self.template_dir),
                '{0}/chooser.js'.format(self.template_dir),
                context
            )
163614
def form(self, obj=None, form=None, name=None, template=None, var_name=None, validate_on_submit=True,\
        exit_on_failure=True, csrf_enabled=None):
        
        if not form or isinstance(form, str):
            if not name and isinstance(form, str):
                name = form
            if not name:
                name = request.endpoint.rsplit('.', 1)[1] if '.' in request.endpoint else request.endpoint
            if name not in self.forms:
                raise NoFormError("Cannot find form '%s'" % name)
            form = self.forms[name]
        if inspect.isclass(form):
            if isinstance(obj, dict):
                obj = DictObject(obj)
            if csrf_enabled is None:
                csrf_enabled = self.options["csrf_enabled"]
            form = form(obj=obj, meta={'csrf': csrf_enabled})

        current_context.data.form = form
        yield form

        if validate_on_submit and request.method == "POST":
            self.validate(form, exit_on_failure=exit_on_failure)
884084
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return FormInstance(self._version, payload, form_type=self._solution['form_type'], )
1149812
def obj_to_dict(cls, obj):
        
        data = {}
        for field_name in cls.get_fields():
            try:
                value = getattr(obj, field_name)
            except AttributeError:
                # If the field doesn't exist on the object, fail gracefully
                # and don't include the field in the data dict at all. Fail
                # loudly if the field exists but produces a different error
                # (edge case: accessing an *existing* field could technically
                # produce an unrelated AttributeError).
                continue

            if callable(value):
                value = value()
            data[field_name] = value

        return data
76890
def get_objects(self):
        
        objects = {}
        for key in six.iterkeys(self.form_classes):
            objects[key] = None
        return objects
98390
def get_value(self, dictionary):
        
        if html.is_html_input(dictionary):
            # HTML forms will represent empty fields as '', and cannot
            # represent None or False values directly.
            if self.field_name not in dictionary:
                if getattr(self.root, 'partial', False):
                    return empty
                return self.default_empty_html
            ret = dictionary[self.field_name]
            if ret == '' and self.allow_null:
                # If the field is blank, and null is a valid value then
                # determine if we should use null instead.
                return '' if getattr(self, 'allow_blank', False) else None
            elif ret == '' and not self.required:
                # If the field is blank, and emptyness is valid then
                # determine if we should use emptyness instead.
                return '' if getattr(self, 'allow_blank', False) else empty
            return ret
        return dictionary.get(self.field_name, empty)
1186516
function ( obj ) {
		return obj.nodeName === "FORM" ? false : string.isUrl( obj.value || element.text( obj ) );
	}
1098782
function (obj) {
        var formData = new FormData();
        _.forOwn(obj, function (value, key) {
            _.isArray(value) ? _.forEach(value, function (eachValue) {
                formData.append(key, eachValue)
            }) : formData.append(key, value);
        });
        return {
            body: formData
        };
    }
84339
def show_edit_form(obj, attrs=None, title="", toolTips=None):
    

    if attrs is None:
        if hasattr(obj, "keys"):
            attrs = list(obj.keys())
        else:
            raise RuntimeError("attrs is None and cannot determine it from obj")

    specs = []
    for i, name in enumerate(attrs):
        # Tries as attribute, then as key
        try:
            value = obj.__getattribute__(name)
        except AttributeError:
            value = obj[name]

        if value is None:
            value = ""  # None becomes str

        dict_ = {"value": value}

        if toolTips is not None:
            dict_["toolTip"] = toolTips[i]
            dict_["tooltip"] = toolTips[i]

        specs.append((name, dict_))
    form = XParametersEditor(specs=specs, title=title)
    r = form.exec_()
    return r, form
589748
def query_form_data(self):
        
        form_data = {}
        slice_id = request.args.get('slice_id')
        if slice_id:
            slc = db.session.query(models.Slice).filter_by(id=slice_id).one_or_none()
            if slc:
                form_data = slc.form_data.copy()

        update_time_range(form_data)

        return json.dumps(form_data)