Renders a scopes picker field in a filter form.
 form - FilterFormBuilder object
 name - attribute name
 checkboxes_on_top - Show picker values on top (default) or below the picker prompt

 Returns nothing.
187626
def scopes_picker_filter(form, name, checkboxes_on_top = true)
      options = {
        multiple: true,
        legend_title: I18n.t("decidim.scopes.scopes"),
        label: false,
        checkboxes_on_top: checkboxes_on_top
      }

      form.scopes_picker name, options do |scope|
        {
          url: decidim.scopes_picker_path(
            root: try(:current_participatory_space)&.scope,
            current: scope&.id,
            title: I18n.t("decidim.scopes.prompt"),
            global_value: "global"
          ),
          text: scope_name_for_picker(scope, I18n.t("decidim.scopes.prompt"))
        }
      end
    end
550331
public function RenderControl () {
		$attrsStr = $this->renderControlAttrsWithFieldVars([
			'autoComplete',
		]);
		if (!$this->form->GetFormTagRenderingStatus()) 
			$attrsStr .= (strlen($attrsStr) > 0 ? ' ' : '')
				. 'form="' . $this->form->GetId() . '"';
		$formViewClass = $this->form->GetViewClass();
		return $formViewClass::Format(static::$templates->control, [
			'id'		=> $this->id,
			'name'		=> $this->name,
			'type'		=> $this->type,
			'value'		=> htmlspecialchars($this->value, ENT_QUOTES),
			'attrs'		=> strlen($attrsStr) > 0 ? ' ' . $attrsStr : '',
		]);
	}
19215
protected function renderFilterCellContent()
    {
        if (is_string($this->filter)) {
            echo $this->filter;
        } else {
            if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos(
                    $this->name,
                    '.'
                ) === false
            ) {
                if ($this->filterInputOptions) {
                    $filterInputOptions = $this->filterInputOptions;
                    if (empty($filterInputOptions['id'])) {
                        $filterInputOptions['id'] = false;
                    }
                } else {
                    $filterInputOptions = array();
                }
                if (is_array($this->filter)) {
                    $filterInputOptions['prompt'] = '';
                    echo TbHtml::activeDropDownList(
                        $this->grid->filter,
                        $this->name,
                        $this->filter,
                        $filterInputOptions
                    );
                } else {
                    if ($this->filter === null) {
                        echo TbHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions);
                    }
                }
            } else {
                parent::renderFilterCellContent();
            }
        }
    }
430476
def find_field_by_name(browser, field_type, name):
    
    return ElementSelector(
        browser,
        field_xpath(field_type, 'name') %
        string_literal(name),
        filter_displayed=True,
    )
1236772
def formfield(self, form_class=None, choices_form_class=None, **kwargs):
        """"""
        defaults = {
            'form_class': form_class or self.get_form_class()
        }
        defaults.update(kwargs)

        return super(ListField, self).formfield(**defaults)
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;
    }
1167993
protected void setFilterForm(FilterForm filterForm) {
		if (this.filterForm != null) {
			validationResultsModel.remove(this.filterForm.getFormModel()
					.getValidationResults());
		}

		this.filterForm = filterForm;

		if (this.filterForm != null) {
			validationResultsModel.add(filterForm.getFormModel()
					.getValidationResults());
		}
	}
1079838
def render_choicefield(field, attrs, choices=None):
	
	# Allow custom choice list, but if no custom choice list then wrap all
	# choices into the `wrappers.CHOICE_TEMPLATE`
	if not choices:
		choices = format_html_join("", wrappers.CHOICE_TEMPLATE, get_choices(field))

	# Accessing the widget attrs directly saves them for a new use after
	# a POST request
	field.field.widget.attrs["value"] = field.value() or attrs.get("value", "")

	return wrappers.DROPDOWN_WRAPPER % {
		"name": field.html_name,
		"attrs": pad(flatatt(field.field.widget.attrs)),
		"placeholder": attrs.get("placeholder") or get_placeholder_text(),
		"style": pad(attrs.get("_style", "")),
		"icon": format_html(wrappers.ICON_TEMPLATE, attrs.get("_dropdown_icon") or "dropdown"),
		"choices": choices
	}
718714
def form_valid(self, form):
        
        #noinspection PyAttributeOutsideInit
        self.object = form.save()

        # Index the link.
        for backend in get_search_backends():
            backend.add(self.object)

        #noinspection PyUnresolvedReferences
        return render_modal_workflow(
            self.request,
            None,
            '{0}/chosen.js'.format(self.template_dir),
            {'obj': self.get_json(self.object)}
        )
89272
def bind(self, name, filterset):
        
        if self.name is not None:
            name = self.name
        self.field.bind(name, self)
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
1344504
def scopes_multi_checkbox(field, **kwargs):
    """"""
    kwargs.setdefault('type', 'checkbox')
    field_id = kwargs.pop('id', field.id)

    html = [u'<div class="row">']

    for value, label, checked in field.iter_choices():
        choice_id = u'%s-%s' % (field_id, value)

        options = dict(
            kwargs,
            name=field.name,
            value=value,
            id=choice_id,
            class_=' ',
        )

        if checked:
            options['checked'] = 'checked'

        html.append(u'<div class="col-md-3">')
        html.append(u'<label for="{0}" class="checkbox-inline">'.format(
            choice_id
        ))
        html.append(u'<input {0} /> '.format(widgets.html_params(**options)))
        html.append(u'{0} <br/><small class="text-muted">{1}</small>'.format(
            value, label.help_text
        ))
        html.append(u'</label></div>')
    html.append(u'</div>')

    return HTMLString(u''.join(html))
509475
def process_form(self, instance, field, form, empty_marker=None,
                     emptyReturnsMarker=False):
        

        # a poor workaround for Plone repeating itself.
        # XXX this is important XXX
        key = field.getName() + '_value'
        if key in instance.REQUEST:
            return instance.REQUEST[key], {}
        value = form.get(field.getName(), empty_marker)
        # When a recordswidget's visibility is defined as hidden
        # '...visible={'view': 'hidden', 'edit': 'hidden'},...' the template
        # displays it as an input field with the attribute 'value' as a string
        # 'value="[{:},{:}]"'. This makes the system save the content of the
        # widget as the string instead of a dictionary inside a list, so we
        # need to check if the variable contains a python object as a string.
        if value and value is not empty_marker and isinstance(value, str):
            import ast
            try:
                value = ast.literal_eval(form.get(field.getName()))
            except:
                # cannot resolve string as a list!
                return empty_marker

        if not value:
            return value, {}
        if value is empty_marker:
            return empty_marker
        if emptyReturnsMarker and value == '':
            return empty_marker

        # we make sure that empty "value" inputs are saved as "" empty string.
        for i in range(len(value)):
            value[i] = dict(value[i])
            if 'value' not in value[i]:
                value[i]['value'] = ''

        instance.REQUEST[key] = value
        return value, {}
1211072
public function filterFields()
    {
        // If filtering is unlocked/allowed we can start with filtering process.
        if (!$this->isFilteringLocked()) {
            $filters = array_filter($this->getFilters());

            if (count($filters)) {
                $dotForm = $this->formHelper->transformToDotSyntax($this->getName());

                $request = $this->getRequest();
                $requestData = $request->all();

                foreach ($filters as $field => $fieldFilters) {
                    $dotField = $this->formHelper->transformToDotSyntax($field);
                    $fieldData = Arr::get($requestData, $dotField);
                    if ($fieldData !== null) {
                        // Assign current Raw/Unmutated value from request.
                        $localDotField = preg_replace('#^' . preg_quote("$dotForm.", '#') . '#', '', $dotField);
                        $localBracketField = $this->formHelper->transformToBracketSyntax($localDotField);
                        $this->getField($localBracketField)->setRawValue($fieldData);
                        foreach ($fieldFilters as $filter) {
                            $filterObj = FilterResolver::instance($filter);
                            $fieldData = $filterObj->filter($fieldData);
                        }
                        Arr::set($requestData, $dotField, $fieldData);
                    }
                }

                foreach ($requestData as $name => $value) {
                    $request[$name] = $value;
                }
            }
        }

        return $this;
    }
336038
function(fieldName) {
                return _.has(this.filterableFields, fieldName) &&
                    !_.isUndefined(this.filterableFields[fieldName].displayName);
            }
766371
def filter_by_widget(self, widget_type):
        
        self._check_layout_and_form()
        layout_field_names = self.layout.get_field_names()

        # Let's filter all fields with widgets like widget_type
        filtered_fields = []
        for pointer in layout_field_names:
            if isinstance(self.form.fields[pointer[1]].widget, widget_type):
                filtered_fields.append(pointer)

        return LayoutSlice(self.layout, filtered_fields)
1342771
def render_iconchoicefield(field, attrs):
	
	choices = ""

	# Loop over every choice to manipulate
	for choice in field.field._choices:
		value = choice[1].split("|")  # Value|Icon

		# Each choice is formatted with the choice value being split with
		# the "|" as the delimeter. First element is the value, the second
		# is the icon to be used.
		choices += format_html(
			wrappers.ICON_CHOICE_TEMPLATE,
			choice[0],  # Key
			mark_safe(wrappers.ICON_TEMPLATE.format(value[-1])),  # Icon
			value[0]  # Value
		)

	# Render a dropdown field
	return render_choicefield(field, attrs, choices)