Starting from CubicWeb version 4.0 all code related to generating html views has been moved to the Cube cubicweb_web.

If you want to migrate a project from 3.38 to 4.* while still using all the html views you need to both install the cubicweb_web cube AND add it to your dependencies and run add_cube('web').

cubicweb_web can be installed from pypi this way:

pip install cubicweb_web

We don’t plan to maintain the features in cubicweb_web in the long run; we are moving to a full javascript frontend using both cubicweb_api (which exposes a HTTP API) and @cubicweb/client as a frontend javascript toolkit.

In the long run cubicweb_api will be merged inside of CubicWeb.

Configuring the user interface#

Relation tags#

A RelationTag object is an object which allows to link a configuration information to a relation definition. For instance, the standard primary view uses a RelationTag object (uicfg.primaryview_section) to get the section to display relations.

# display ``entry_of`` relations in the ``relations`` section in the ``BlogEntry`` primary view
uicfg.primaryview_section.tag_subject_of(('BlogEntry', 'entry_of', '*'),

# hide every relation ``entry_of`` in the ``Blog`` primary view
uicfg.primaryview_section.tag_object_of(('*', 'entry_of', 'Blog'), 'hidden')
Three primitives are defined:
  • tag_subject_of tag a relation in the subject’s context

  • tag_object_of tag a relation in the object’s context

  • tag_attribute shortcut for tag_subject_of

The uicfg module#


The part of uicfg that deals with primary views is in the Primary view configuration chapter.

This module (cubicweb_web.views.uicfg) regroups a set of structures that may be used to configure various options of the generated web interface.

To configure the interface generation, we use RelationTag objects.

Index view configuration#


entity type category in the index/manage page. May be one of:

  • application

  • system

  • schema

  • subobject (not displayed by default)

By default only entities on the application category are shown.

from cubicweb_web.views import uicfg
# force hiding
uicfg.indexview_etype_section['HideMe'] = 'subobject'
# force display
uicfg.indexview_etype_section['ShowMe'] = 'application'

Actions box configuration#


simple boolean relation tags used to control the “add entity” submenu. Relations whose rtag is True will appears, other won’t.

# Adds all subjects of the entry_of relation in the add menu of the ``Blog``
# primary view
uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True)

The uihelper module#

This module provide highlevel helpers to avoid uicfg boilerplate for most common tasks such as fields ordering, widget customization, etc.

Here are a few helpers to customize action box rendering:

cubicweb_web.uihelper.append_to_addmenu(etype, attr, createdtype='*') Callable#
cubicweb_web.uihelper.remove_from_addmenu(etype, attr, createdtype='*') Callable#

and a few other ones for form configuration:

cubicweb_web.uihelper.set_fields_order(etype, attrs) Callable#
cubicweb_web.uihelper.hide_field(etype, attr, desttype='*', formtype='main') Callable#
cubicweb_web.uihelper.hide_fields(etype, attrs, formtype='main') Callable#
cubicweb_web.uihelper.set_field_kwargs(etype, attr, **kwargs) Callable#
cubicweb_web.uihelper.set_field(etype, attr, field) Callable#
cubicweb_web.uihelper.edit_inline(etype, attr, desttype='*', formtype=('main', 'inlined')) Callable#
cubicweb_web.uihelper.edit_as_attr(etype, attr, desttype='*', formtype=('main', 'muledit')) Callable#
cubicweb_web.uihelper.set_muledit_editable(etype, attrs) Callable#

The module also provides a FormConfig base class that lets you gather uicfg declaration in the scope of a single class, which can sometimes be clearer to read than a bunch of sequential function calls.

class cubicweb_web.uihelper.FormConfig[source]#

helper base class to define uicfg rules on a given entity type.

In all descriptions below, attributes list can either be a list of attribute names of a list of 2-tuples (relation name, role of the edited entity in the relation).



which entity type the form config is for. This attribute is mandatory


the formtype the class tries toc customize (i.e. main, inlined, or muledit), default is main.


the list of attributes or relations to hide.


the list of attributes to edit in the attributes section.


the list of attributes to edit in the inlined section.


the list of attributes to edit, in the desired order. Unspecified fields will be displayed after specified ones, their order being consistent with the schema definition.


a dictionary mapping attribute names to widget instances.


a dictionary mapping attribute names to field instances.


an instance of cubicweb_web.uicfg.AutoformSectionRelationTags Default is None, meaning cubicweb_web.uicfg.autoform_section is used.


an instance of cubicweb_web.uicfg.AutoformFieldTags Default is None, meaning cubicweb_web.uicfg.autoform_field is used.


an instance of cubicweb_web.uicfg.AutoformFieldKwargsTags Default is None, meaning cubicweb_web.uicfg.autoform_field_kwargs is used.


from cubicweb_web import uihelper, formwidgets as fwdgs

class LinkFormConfig(uihelper.FormConfig):
    etype = 'Link'
    hidden = ('title', 'description', 'embed')
    widgets = dict(

class UserFormConfig(uihelper.FormConfig):
    etype = 'CWUser'
    hidden = ('login',)
    rels_as_attrs = ('in_group',)
    fields_order = ('firstname', 'surname', 'in_group', 'use_email')
    inlined = ('use_email',)