PHPackages                             sergsxm/ui-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. sergsxm/ui-bundle

ActiveLibrary[Templating &amp; Views](/categories/templating)

sergsxm/ui-bundle
=================

Sergsxm UIBundle provides functions for creating forms and table lists

1.1.3(9y ago)023MITPHPPHP &gt;=5.3.9

Since Feb 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Sergsxm/UIBundle)[ Packagist](https://packagist.org/packages/sergsxm/ui-bundle)[ RSS](/packages/sergsxm-ui-bundle/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (9)Dependencies (3)Versions (10)Used By (0)

Sergsxm UIBundle
================

[](#sergsxm-uibundle)

It`s bundle for Symfony2 framework, which provides functions for creating forms, table lists and tree (order) forms. This is useful when creating a site`s backend.

**The bundle being developed, be careful when using in projects.**

Forms features:

- The fields are combined into groups
- Control the visibility of the groups, depending on fields conditions
- JavaScript validation
- Advanced templating with field`s templates replacement
- Ajax file upload

Table lists features:

- Use Doctrine
- Support for tabs
- Sort by all fields
- Text search function
- Ajax actions
- Saving the sorting settings, search settings, current page etc. in session

Tree (order) forms features:

- Use Doctrine
- Easy tree or order setup by JavaScript
- Supports mouse and touchscreen

1. Installation
---------------

[](#1-installation)

To install SergsxmUIBundle, run `composer require sergsxm/ui-bundle`.

Register the bundle in the app/AppKernel.php file:

```
...
public function registerBundles()
{
    $bundles = array(
        ...
        new Sergsxm\UIBundle\SergsxmUIBundle(),
        ...
    );
...
```

Register the bundle in the app/config/routing.yml file:

```
...
sergsxm_ui:
    resource: "@SergsxmUIBundle/Resources/config/routing.yml"
    prefix:   /
...
```

Install bundle assets by command `php app/console assets:install`.

Now you can use the bundle.

If you will change layout template, remember to add CSS and JS files of this bundle and initialization section on it (and Bootstrap, jQuery, TinyMCE files of course):

```

        ...
        ...

            sergsxmUIFunctions.initContext('{{app.request.locale}}', '{{path('sergsxm_ui_file_upload')}}');

    ...
    ...

```

### 1.1. Third-party modules

[](#11-third-party-modules)

For the operation of the bundle following modules needed:

[Bootstrap](http://getbootstrap.com/)

[jQuery](https://jquery.com/)

[TinyMCE](https://www.tinymce.com/) (optionaly, used for html input type in forms)

[Yandex.maps](https://tech.yandex.ru/maps/) (optionaly, used for address input type in forms)

2. Forms usage
--------------

[](#2-forms-usage)

### 2.1. Form creation

[](#21-form-creation)

To create the form use the service:

```
$form = $this->get('sergsxm.ui')->createForm($object);
```

$object is a object for properties mapping. Leave this parameter or set it to null if this functionality is not needed.

Now you have Form (Sergsxm\\UIBundle\\Form\\Form) object. This object contains following methods:

```
public function addField($type, $name, $configuration = array(), $mappingObject = self::MO_PARENT);
public function openGroup($name, $description = '', $condition = '');
public function closeGroup();
public function enableCaptcha($type, $configuration = array());
public function disableCaptcha();
public function getFormId();
public function setFormId($formId);
public function setReadOnly($readOnly);
public function bindRequest(Request $request = null);
public function clear();
public function getResult();
public function getView();
public function renderView($template = 'SergsxmUIBundle:Form:Form.html.twig', $parameters = array());
public function render($template = 'SergsxmUIBundle:Form:Form.html.twig', $parameters = array(), Response $response = null);
public function findInputByName($name);
public function getValue();
public function setValue($value);
public function fromAnnotations($tag = null, $mappingObject = self::MO_PARENT);
```

Assigning functions described in greater detail in the class file.

Below is a code example of using form:

```
$object = new \StdClass();
$object->text1 = 'foo';
$object->textarea1 = '';
$object->select1 = '';
$object->checkbox1 = '';
$object->password1 = '';
$object->timestamp1 = '';
$object->html1 = '';
$object->file1 = null;

$form = $this->get('sergsxm.ui')->createForm($object);

$form
    ->addField('text', 'text1')
    ->openGroup('test', 'Test group', '')
    ->addField('textarea', 'textarea1')
    ->addField('select', 'select1', array(
        'choices' => ['One', 'Two', 'Three'],
    ))
    ->openGroup('test1', 'Subgroup', 'select1 == 1')
    ->addField('checkbox', 'checkbox1')
    ->addField('password', 'password1')
    ->closeGroup()
    ->addField('timestamp', 'timestamp1')
    ->openGroup('test2', 'Subgroup 2')
    ->addField('html', 'html1')
    ->enableCaptcha('standart')
    ->addField('file', 'file1', array(
        'storeType' => \Sergsxm\UIBundle\FormInputTypes\File::ST_FILE,
        'storeFolder' => 'uploadfiles',
    ));
if ($form->bindRequest()) {
    echo 'Data saved!';
    var_dump($form->getValue());
    var_dump($object);
    $form->clear();
    die;
}

return $form->render('SergsxmUIBundle:Form:Form.html.twig', array('title' => 'New form', 'backUrl' => '/123'));
```

### 2.2. Object`s properties mapping

[](#22-objects-properties-mapping)

If you create a form specified object for properties mapping, the form values are automatically transferred to the object properties with the same name. Make sure it is possible in the example above. Also, for each field , you can specify another object (see 4 parameter for addField method).

If you do not need this feature, you can specify in the configuration of the field `'mapping' => false`.

### 2.3. Input types

[](#23-input-types)

Supported input types: checkbox, text, textarea, timestamp, html, password, select, file, number, image, address, tag, category.

Type **checkbox** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field must be checked"uncheckedValueValue for unchecked conditionfalsecheckedValueValue for checked conditiontruedisabledSet field to disabled statefalseType **text** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"regexpRegular expression with which the entered text will be checked"/^\[\\s\\S\]\*$/i"regexpErrorText for the "regular expression" error"The field is not valid"validateCallbackUser-defined function to check the field (see below)nullvalidateCallbackParametersAdditional parameters for validateCallback functionnulluniqueInDoctrineEnables checking the uniqueness of the field in the Doctrine databasefalseuniqueErrorText for the "unique" error"This value already exists in the database"trimTrim valuefalsedisabledSet field to disabled statefalseType **email** is same as **text** type with predefined regexp.

Type **textarea** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"regexpRegular expression with which the entered text will be checked"/^\[\\s\\S\]\*$/i"regexpErrorText for the "regular expression" error"The field is not valid"disabledSet field to disabled statefalseType **timestamp** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"dateTimeFormatTimestamp format accepted by [date()](http://php.net/manual/en/function.date.php) function"Y-m-d\\TH:i:s"formatErrorText for the "datetime format" error"Bad datetime format"timeZoneTimezone (string or \\DateTimeZone or null)nulldisabledSet field to disabled statefalseType **html** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"disableFiltersTurns off all HTML filters, the field value is passed as isfalseallowTagsIf filled all tags other than listed, will be removed (format: "h1,p,a")nullallowStylePropertyIf false all "style" attributes will be removedtruereplaceUrlIf true all links will be replaced with JavaScript calls or redirectfalsereplaceUrlPathLinks will be replaced with redirect to this URL with "path" get-parameternulldisabledSet field to disabled statefalseType **password** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"encoderPasswordEncoderInterface to encode password, or null, or "@factory" to use security.encoder\_factory servicenullrepeatIf true it requires password repetitionfalserepeatErrorText for the "repeat" error"Values​do not match"repeatDescriptionRepeat field description, which will be displayed to the user""mapNullValuesIf false, the mapping property will not change when field is emptytrueregexpRegular expression with which the entered text will be checked"/^\[\\S\]{5,99}$/i"regexpErrorText for the "regular expression" error"The field is not valid"randomizeSaltIf true salt will be replaces by random valuetruemappingSaltPropertyProperty name to store salt value in mapping object""disabledSet field to disabled statefalseType **select** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"choicesAn array of possible valuesarray()choicesErrorText for the error when value do not find in *choices* array"The field contain bad value"multiplyIf true possible to select multiple valuesfalseexpandedIf true *select* will show extended (radio buttons, checkboxes)falseexplodeValueOnly for multiply select: if true output value will be exploded to string (if false - array)falseexplodeSeparatorExplode separator (when *explodeValue* is true)","disabledSet field to disabled statefalseType **file** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"maxSizeMaximum allowed file size (null for unlimited)nullmaxSizeErrorText for oversize error"File size is larger than allowed"mimeTypesArray of allowed MIME types (null for disable filter)nullmimeTypesErrorText for MIME type error"Invalid file type"storeTypeType of file store (see below)ST\_FILEstoreFolderFolder for saving files"uploads"storeDoctrineClassDoctrine file entity class (must implements Sergsxm\\UIBundle\\Classes\\FileInterface)""multiplyIf true possible to upload multiply files in one fieldfalsedisabledSet field to disabled statefalseType **number** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"decimalPointSets the separator for the decimal point"."thousandSeparatorSets the thousands separator""decimalsSets the number of decimal points (or null for disable option)nullminValueSets minimal value (or null for disable option)nullmaxValueSets maximal value (or null for disable option)nullvalueErrorText for the "limits" error"The number is beyond the set limits"notNumberErrorText for the "not a number" error"This is not a number"disabledSet field to disabled statefalseType **image** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"maxSizeMaximum allowed file size (null for unlimited)nullmaxSizeErrorText for oversize error"File size is larger than allowed"minWidthMinimal image width (null for unlimited)nullminHeightMinimal image height (null for unlimited)nullmaxWidthMaximal image width (null for unlimited)nullmaxHeightMaximal image height (null for unlimited)nullimageSizeErrorText for image size error"Wrong image size"notImageErrorText for "not an image" error"The file is not an image"storeTypeType of file store (see below)ST\_FILEstoreFolderFolder for saving files"uploads"storeDoctrineClassDoctrine file entity class (must implements Sergsxm\\UIBundle\\Classes\\ImageInterface)""multiplyIf true possible to upload multiply images in one fieldfalsedisabledSet field to disabled statefalseType **address** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"mapEnabledIf true map is enabled in fieldfalsemappingCoordinatesPropertyProperty name to store coordinates from mapnulldisabledSet field to disabled statefalseType **tag** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"doctrineClassDoctrine tag entity class (must inplements Sergsxm\\UIBundle\\Classes\\TagInterface)nulltagPropertyProperty name in entity class to find tags in database'tag'createCallbackFunction that call when tag entity create (after set tag and before persist)nulldisabledSet field to disabled statefalseType **category** has following settings:

ParameterParameter descriptionDefault valuedescriptionField description, which will be displayed to the user as the field namesuch as field namerequiredIf true field is requiredfalserequiredErrorText for the "required" error"The field can not be empty"categoriesAn array of categories (each element must implements Sergsxm\\UIBundle\\Classes\\TreeInterface)array()categoriesErrorText for the error when value do not find in *categories* array"The field contain bad value"multiplyIf true possible to select multiple categoriesfalseexpandedIf true *select* will show extended (radio buttons, checkboxes)falsemapIdToValueIf true only category ID will be placed as value of mapping propertyfalseloadDoctrineRepositoryAllow to load categories from Doctrine repository (otherwise - by *categories* parameter)nulldisabledSet field to disabled statefalse*ValidateCallback* function must be callable. The function should return null (if field value is valid) or error text. The first parameter passed to the function is the value of the field. The second parameter specifies by parameter *validateCallbackParameters*.

*StoreType* specifies the type of save file. Types defined by constants in the class \\Sergsxm\\UIBundle\\FormInputTypes\\File (\\Sergsxm\\UIBundle\\FormInputTypes\\Image for image type). There are two types: ST\_FILE and ST\_DOCTRINE. When you type ST\_FILE file is saved in *storeFolder* folder. The file with the extension info, which stores information about the file, will creates in the same folder. Filename will be used as value for the mapping property. When you type ST\_DOCTRINE file is also stored in *storeFolder* folder. File information is stored in a database in entity *storeDoctrineClass*. This entity will be used as value for the mapping property. *Note: storeFolder must be protected from external access for security.*

You can also specify a placeholder for the fields and the captcha through *placeholder* configuration parameter.

### 2.4. Captcha types

[](#24-captcha-types)

Supported captcha types: standart.

Type **standart** has following settings:

ParameterParameter descriptionDefault valuedescriptionCaptcha field description, which will be displayed to the user as the field namesuch as field namevalidateErrorText for validation error"Values do not match"widthCaptcha image width (in pixels)150heightCaptcha image height (in pixels)50backgroundBackground color for captcha image (CSS like string)"fff"colorMain color for captcha image (CSS like string)"000"noiseEnable noise linesfalselengthLength of text6lettersAllowed letters"123456789ABCDEFGHIJKLMNPQRSTUVWXYZ"fontTTF font file for captcha lettersnull means internal font### 2.5. Advanced templating

[](#25-advanced-templating)

Default simple form`s template are placed in **SergsxmUIBundle:Form:Form.html.twig**. Field`s and group`s parameters are transferred to the group default template **SergsxmUIBundle:Form:FormGroup.html.twig**. In this template, field`s parameters are transferre to the field default templates, witch places into **SergsxmUIBundle:FormInputTypes:**. You can change the default templates, but you can describe the output of individual fields in the group template:

```
{% if root|default(false) == false %}

        {% if description != '' %}
            {{description}}
        {% endif %}
{% endif %}
        {% for field in fields %}
            {% if field['type'] == 'text' %}
                ...
                ...
            {% else %}
                {% include field['defaultTemplate'] with field only %}
            {% endif %}
        {% endfor %}
        {% for group in groups %}
            {% include group['defaultTemplate'] with group only %}
        {% endfor %}
{% if root|default(false) == false %}

{% endif %}
```

So you can create your own templates and put them when calling the render methods of form object.

You can also specify a template for the fields and the captcha through *template* configuration parameter.

### 2.6. Annotations

[](#26-annotations)

You can create forms from the annotations of mapping object. For this purpose use method `fromAnnotations($formName = null, $mappingObject = self::MO_PARENT)`.

Annotation `Sergsxm\UIBundle\Annotations\FormField` is used to create input fields. Type and configuration parameters are directly passed to the method *addField*.

Example:

```
    /**
     * @var string
     *
     * @\Sergsxm\UIBundle\Annotations\FormField(type="text", configuration={"description"="File name", "required"=true, "requiredError"="The field can not be empty"})
     */
    private $fileName;
```

To localize the phrases in annotation there is option: translate. Option *translate* is an array that contains the keys of the configuration array that need to be localized. Also you can specified translator domain by 'Sergsxm\\UIBundle\\Annotations\\TranslationDomain' class annotation.

Example:

```
/**
 * @\Sergsxm\UIBundle\Annotations\TranslationDomain("sergsxmui")
 */
class FileEntity
{
    /**
     * @var string
     *
     * @\Sergsxm\UIBundle\Annotations\Description("File name field")
     * @\Sergsxm\UIBundle\Annotations\FormField(
     *      type="text",
     *      configuration={"description"="File name", "required"=true, "requiredError"="The field can not be empty"},
     *      translate={"description", "requiredError"})
     */
    private $fileName;
```

Annotation `Sergsxm\UIBundle\Annotations\Description` is used to set field description. This value will be translated.

Class annotation `Sergsxm\UIBundle\Annotations\Form` is used to setup forms of object. There are three parameters: name, groups and fields. Parameter *name* contains form name. When you call a method `fromAnnotations($formName)` form with this name will be loaded. Parameter *groups* contains information about all groups. Parameter *fields* contains form structure.

Example:

```
/**
 * @\Sergsxm\UIBundle\Annotations\Form(
 *      name="user",
 *      groups={
 *          {"name"="first", "description"="First group"},
 *          {"name"="second", "description"="Second group"}
 *      },
 *      fields={"fileName", "first"={"contentFile"}, "second"={"mimeType"}}
 * )
 * @\Sergsxm\UIBundle\Annotations\TranslationDomain("sergsxmui")
 */
class FileEntity
{
    /**
     * @var string
     *
     * @\Sergsxm\UIBundle\Annotations\Description("File name")
     * @\Sergsxm\UIBundle\Annotations\FormField(
     *      type="text",
     *      configuration={"required"=true, "requiredError"="Field required"},
     *      translate={"requiredError"})
     */
    private $fileName;

    /**
     * @var string
     *
     * @\Sergsxm\UIBundle\Annotations\FormField(type="text", configuration={"description"="MIME", "required"=true, "requiredError"="Field required"})
     */
    private $mimeType;

    /**
     * @var string
     *
     * @\Sergsxm\UIBundle\Annotations\FormField(type="text", configuration={"description"="Content file"})
     */
    private $contentFile;
```

3. Table lists usage
--------------------

[](#3-table-lists-usage)

### 3.1. Table list creation

[](#31-table-list-creation)

To create the table list use the service:

```
$list = $this->get('sergsxm.ui')->createTableList();
```

Now you have TableList (Sergsxm\\UIBundle\\TableList\\TableList) object. This object contains following methods:

```
public function addTab($repository, $name, $configuration = null);
public function getTab($name);
public function bindRequest(Request $request = null);
public function getView();
public function renderView($template = 'SergsxmUIBundle:TableList:TableList.html.twig', $ajaxTemplate = 'SergsxmUIBundle:TableList:TableListAjax.html.twig', $parameters = array());
public function render($template = 'SergsxmUIBundle:TableList:TableList.html.twig', $ajaxTemplate = 'SergsxmUIBundle:TableList:TableListAjax.html.twig', $parameters = array(), Response $response = null);
```

Methods addTab adn getTab returns TableListTab (Sergsxm\\UIBundle\\TableList\\TableListTab) object. This object contains following external methods:

```
public function addWhereCondition($dql, $condition, $parameter);
public function openWhereGroup($whereType);
public function closeWhereGroup();
public function groupBy($dql);
public function addColumn($type, $name, $configuration = array());
public function addUrlAction($name, $url, $configuration = array());
public function addAjaxAction($name, $sql, $configuration = array());
public function getDescription();
```

In a few words, when you create the tab, you specified Doctrine repository. When you add any column as the name specified the name of the field in the repository. Thus it is possible to build a simple table. For advanced tasks see section *Advanced queries*.

Assigning functions described in greater detail in the class file.

Below is a code example of using table lists:

```
$list = $this->get('sergsxm.ui')->createTableList();

$list
    ->addTab('TestBundle:FileEntity', 'files', array('description' => 'Files', 'countEnabled' => true))
    ->addColumn('text', 'fileName', array('description' => 'File name', 'searchEnabled' => true))
    ->addColumn('text', 'mimeType', array('description' => 'MIME type'))
    ->addColumn('timestamp', 'uploadDate', array('description' => 'Upload date'))
    ->addAjaxAction('delete', 'DELETE FROM TestBundle:FileEntity f WHERE f.id IN (:ids)', array('confirmed' => true))
    ->addAjaxAction('set_jpeg', 'UPDATE TestBundle:FileEntity f SET f.mimeType = \'image/jpeg\' WHERE f.id IN (:ids)')
    ->addAjaxAction('set_png', 'UPDATE TestBundle:FileEntity f SET f.mimeType = \'image/png\' WHERE f.id IN (:ids)')
    ->addUrlAction('new', '/admin/edit');
$list
    ->addTab('TestBundle:FileEntity', 'files2', 'Files 2')
    ->addColumn('text', 'fileName', array('description' => 'File name', 'searchEnabled' => true))
    ->addColumn('text', 'mimeType', array('description' => 'MIME type'))
    ->addColumn('timestamp', 'uploadDate', array('description' => 'Upload date'))
    ->addAjaxAction('delete', 'DELETE FROM TestBundle:FileEntity f WHERE f.id IN (:ids)', array('confirmed' => true))
    ->addAjaxAction('set_jpeg', 'UPDATE TestBundle:FileEntity f SET f.mimeType = \'image/jpeg\' WHERE f.id IN (:ids)')
    ->addAjaxAction('set_png', 'UPDATE TestBundle:FileEntity f SET f.mimeType = \'image/png\' WHERE f.id IN (:ids)')
    ->addUrlAction('new', '/admin/edit')
    ;

$list->bindRequest();

return $list->render('SergsxmUIBundle:TableList:TableList.html.twig', 'SergsxmUIBundle:TableList:TableListAjax.html.twig');
```

Default configuration of TableListTab:

ParameterParameter descriptionDefault valuedescriptionTab description, which will be displayed at tab buttonsuch as tab namewhereTypeType of root WHERE statment (OR, AND or XOR)TableListQuery::WT\_ORcountEnabledEnables items count display in tab buttonfalse### 3.2. Column types

[](#32-column-types)

Supported column types: text, checkbox, select, timestamp, file, number, image, tag, category.

All column types has following settings:

ParameterParameter descriptionDefault valuedescriptionColumn description, which will be displayed at the table headsuch as column nameurlLink to any page, for example edit page of the row item (format describes below)nullurlTargetValue of target property of linknullhiddenOff column displayfalsedefaultOrderDirectionSets column as default order column and specified direction (0 - ASC, 1 - DESC)unsetType **text** has following personal settings:

ParameterParameter descriptionDefault valueorderEnabledEnables ordering for columntruesearchEnabledEnables search for columnfalsepatternText pattern. In this string statment "{{text}}" will be replaced by cell value"{{text}}"textLimitLimits text lengthnullType **checkbox** has following personal settings:

ParameterParameter descriptionDefault valueuncheckedValueValue for unchecked conditionfalsecheckedValueValue for checked conditiontrueorderEnabledEnables ordering for columntrueuncheckedPatternText pattern for unchecked value""checkedPatternText pattern for checked value""Type **select** has following personal settings:

ParameterParameter descriptionDefault valuechoicesAn array of possible valuesarray()multiplyIf true possible to select multiple valuesfalseexplodeValueOnly for multiply select: if true value exploded to string (if false - array)falseexplodeSeparatorExplode separator (when *explodeValue* is true)","orderEnabledEnables ordering for columntrueimplodeSeparatorImplode separator for output value","Type **timestamp** has following personal settings:

ParameterParameter descriptionDefault valuedateTimeFormatTimestamp format accepted by [date()](http://php.net/manual/en/function.date.php) function"Y-m-d\\TH:i:s"timeZoneTimezone (string or \\DateTimeZone or null)nullorderEnabledEnables ordering for columntrueType **file** has following personal settings:

ParameterParameter descriptionDefault valuestoreTypeType of file store (see file form field description)ST\_FILEmultiplyIf true possible to upload multiply files in one fieldfalseimplodeSeparatorImplode separator for output value","fileUrlLink to any file page, for example edit or download file (format like for url parameter)nullType **number** has following personal settings:

ParameterParameter descriptionDefault valuedecimalPointSets the separator for the decimal point"."thousandSeparatorSets the thousands separator""decimalsSets the number of decimal points (or null for disable option)nullorderEnabledEnables ordering for columntruesearchEnabledEnables search for columnfalseType **image** has following personal settings:

ParameterParameter descriptionDefault valuestoreTypeType of image store (see image form field description)ST\_FILEmultiplyIf true possible to upload multiply files in one fieldfalseimplodeSeparatorImplode separator for output value","imageUrlLink to download image page (format like for url parameter)nullType **tag** has following personal settings:

ParameterParameter descriptionDefault valueimplodeSeparatorImplode separator for output value" "patternPattern for one tag (string statment {{tag}} will be replaced by tag name)"{{tag}}"Type **category** has following personal settings:

ParameterParameter descriptionDefault valuecategoriesAn array of categories (each element must implements Sergsxm\\UIBundle\\Classes\\TreeInterface)array()multiplyIf true possible to contain multiple categoriesfalsemapIdToValueIf true only category ID placed as value of mapping propertyfalseloadDoctrineRepositoryAllow to load categories from Doctrine repository (otherwise - by *categories* parameter)nullimplodeSeparatorImplode separator for output value","categoryUrlLink to any category page, for example view or edit category (format like for url parameter)nullParameter *url* can be two formats. One of formats is string with custom URL (detecting by "/" symbol). In this string statment "{{id}}" will be replaced by row item ID. Second format is string with Symfony route. This string will by processed by Symfony routing service (with route parameter "id").

### 3.3. URL actions

[](#33-url-actions)

Actions are displayed as a list of buttons. There are two types of actions: URL and ajax. URL actions are simple links to other pages on your site (for example, to create a new page). Ajax actions are actions on the selected items in table list. They are processed through the ajax request.

URL actions are added by method `addUrlAction($name, $url, $configuration = array());`. Parameter $name contains technical name of action. Parameter $url is action URL or route name.

URL actions has following additional configuration settings:

ParameterParameter descriptionDefault valuedescriptionAction description, which will be displayed at the buttonsuch as action namepermissionAllows to turn off the button, if it is prohibited by user permissionstruesendIdsIf true checked IDs will be sent to a URL through a GET requestfalsemultiplyIf true it may be checked a lot of rows, if false it is to be checked only one rowtrueconfirmedIf true action requires confirmationfalseconfirmedMessageСonfirmation message"Please confirm this operation"confirmedTitleСonfirmation window title"Warning"confirmedOkLabel for OK button"OK"confirmedCancelLabel for cancel button"Cancel"### 3.4. Ajax actions

[](#34-ajax-actions)

Ajax actions are added by method `addAjaxAction($name, $sql, $configuration = array());`. Parameter $name contains technical name of action. Parameter $sql contains DQL query. It may be a few queries separated by ";". The query can contain parameters :id or :ids.

Ajax actions has following additional configuration settings:

ParameterParameter descriptionDefault valuedescriptionAction description, which will be displayed at the buttonsuch as action namepermissionAllows to turn off the button, if it is prohibited by user permissionstruemultiplyIf true it may be checked a lot of rows, if false it is to be checked only one rowtrueconfirmedIf true action requires confirmationfalseconfirmedMessageСonfirmation message"Please confirm this operation"confirmedTitleСonfirmation window title"Warning"confirmedOkLabel for OK button"OK"confirmedCancelLabel for cancel button"Cancel"callbackCallback function (see below)nullWhen the DQL query is not enough (for example, to verify user permissions for each row), use the callback function. This function is passed an array of identifiers of selected rows. The function should return an errors array (key - row identifier, value - error text).

### 3.5. Advanced queries

[](#35-advanced-queries)

When you create the tab, you specified Doctrine repository. When you add any column as the name specified the name of the field in the repository. As a result, the query will look like this `SELECT item.id, item.{{columnName1}} as col0, item.{{columnName2}} as col1 .... FROM {{repository}} item`.

It has the ability to perform subqueries. To do this, as variable $name write a subquery:

```
    ->addColumn('number', 'SELECT COUNT(m.id) FROM TestBundle:TestEntity m WHERE m.fooFile = item.id', array('description' => 'Use count'))

```

Also, it has the ability to perform join statments. To do this, as variable $name write a select part and add 'join' parameter:

```
    ->addColumn('image', 'file.contentFile JOIN item.fooFile file', array('description' => 'Image'))

```

With methods addWhereCondition, openWhereGroup, closeWhereGroup of TableListTab and with $configuration parameter *whereType* in addTab method of TableList you can manage WHERE statment of DQL.

With method groupBy of TableListTab you can manage GROUP BY statment of DQL.

4. Tree and order forms usage
-----------------------------

[](#4-tree-and-order-forms-usage)

### 4.1. Tree and order form creation

[](#41-tree-and-order-form-creation)

To create the tree form use the service:

```
$list = $this->get('sergsxm.ui')->createTreeForm($configuration, $treeItems);
```

To create the order form use the service:

```
$list = $this->get('sergsxm.ui')->createOrderForm($configuration, $orderListItems);
```

First parameter is a configuration array. Second parameter is array of list items (you may also load all Doctrine repository by specified *loadDoctrineRepository* configuration parameter).

Now you have TreeForm (Sergsxm\\UIBundle\\TreeForm\\TreeForm) or OrderForm (Sergsxm\\UIBundle\\OrderForm\\OrderForm) object.

TreeForm object contains following methods:

```
public function getView();
public function renderView($template = 'SergsxmUIBundle:TreeForm:TreeForm.html.twig', $parameters = array());
public function render($template = 'SergsxmUIBundle:TreeForm:TreeForm.html.twig', $parameters = array(), Response $response = null);
public function setReadOnly($readOnly);
public function getResult();
public function bindRequest(Request $request = null);
public function clear();
public function getFormId();
public function setFormId($formId);
```

OrderForm object contains following methods:

```
public function getView();
public function renderView($template = 'SergsxmUIBundle:OrderForm:OrderForm.html.twig', $parameters = array());
public function render($template = 'SergsxmUIBundle:OrderForm:OrderForm.html.twig', $parameters = array(), Response $response = null);
public function setReadOnly($readOnly);
public function getResult();
public function bindRequest(Request $request = null);
public function clear();
public function getFormId();
public function setFormId($formId);
```

Below is a simple example of using tree forms:

```
$treeForm = $this->get('sergsxm.ui')->createTreeForm(array(
    'createEnabled' => true,
    'createCallback' => array($this, 'createTree'),
    'removeEnabled' => true,
), $this->getDoctrine()->getRepository('\TestBundle\Entity\TreeEntity')->findAll());

if ($treeForm->bindRequest()) {
    $treeForm->clear();
    echo 'Data saved!';
}

return $treeForm->render();
```

### 4.2. Tree and order item entity

[](#42-tree-and-order-item-entity)

Item entity for TreeForm must implements \\Sergsxm\\UIBundle\\Classes\\TreeInterface.

Each tree entity has a parent field and the order field. Value of the parent field can be a parent entity or integer ID (set by configuration). Value of the order field is an integer.

There is also nested set interface \\Sergsxm\\UIBundle\\Classes\\TreeNSInterface that extends TreeInterface. This interface has additionaly methods to set level, left and right keys for nested set algorithms.

Item entity for OrderForm must implements \\Sergsxm\\UIBundle\\Classes\\OrderInterface.

Each order list entity has a order filed.

### 4.3. Configuration parameters

[](#43-configuration-parameters)

TreeForm has following configuration parameters:

ParameterParameter descriptionDefault valuecreateCallbackParameter required when createEnabled is true. Function witch called for tree item creation (see below)nullchangeCallbackFunction witch called after tree item is changed (see below)nullremoveCallbackFunction witch called after tree item is removed (see below)nullurlLink to any page, for example edit page of the tree item (format describes below)nullcreateEnabledIf true create function is enabledfalseremoveEnabledIf true remove function is enabledfalsereadOnlyIf true tree form is locked for editingfalsemapIdToParentPropertyIf true value of the parent field is integer ID, if false - entityfalseloadDoctrineRepositoryAllow to load tree items from Doctrine repository (otherwise, you must specify tree items when you create a form)nullnestedSetFirstIndexFirst index value for nested set keys1Parameter *createCallback* must contains callback function with three parameters: $title, $parent, $order. $title is a title of new tree item. $parent is parent entity or null. $order is order of tree item in tree (integer).

Parameter *changeCallback* must contains callback function with three parameters: $item, $parent, $order. $item is tree item entity. $parent is parent entity or null. $order is order of tree item in tree (integer). This function call after changing parent and order fields of entity.

Parameter *removeCallback* must contains callback function woth one parameter: $item. $item is tree item entity to remove. This function call after call of remove method of entity manager.

Parameter *url* can be two formats. One of formats is string with custom URL (detecting by "/" symbol). In this string statment "{{id}}" will be replaced by row item ID. Second format is string with Symfony route. This string will by processed by Symfony routing service (with route parameter "id").

OrderForm has following configuration parameters:

ParameterParameter descriptionDefault valuecreateCallbackParameter required when createEnabled is true. Function witch called for tree item creation (see below)nullchangeCallbackFunction witch called after tree item is changed (see below)nullremoveCallbackFunction witch called after tree item is removed (see below)nullurlLink to any page, for example edit page of the tree item (format describes above)nullcreateEnabledIf true create function is enabledfalseremoveEnabledIf true remove function is enabledfalsereadOnlyIf true tree form is locked for editingfalseloadDoctrineRepositoryAllow to load list items from Doctrine repository (otherwise, you must specify list items when you create a form)nullParameter *createCallback* must contains callback function with two parameters: $title, $order. $title is a title of new item. $order is order of item in order list (integer).

Parameter *changeCallback* must contains callback function with two parameters: $item, $order. $item is order list item entity. $order is order of item in order list (integer). This function call after changing parent and order fields of entity.

Parameter *removeCallback* must contains callback function woth one parameter: $item. $item is order list item entity to remove. This function call after call of remove method of entity manager.

5. Notes
--------

[](#5-notes)

This bundle is just my own view of how should be organized in forms and lists. The code is few tested and may contain some bugs.

6. License
----------

[](#6-license)

This bundle is under MIT license

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~51 days

Recently: every ~94 days

Total

9

Last Release

3379d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16292394?v=4)[sergsxm](/maintainers/sergsxm)[@Sergsxm](https://github.com/Sergsxm)

---

Top Contributors

[![Sergsxm](https://avatars.githubusercontent.com/u/16292394?v=4)](https://github.com/Sergsxm "Sergsxm (1 commits)")

---

Tags

listformtableextra form

### Embed Badge

![Health badge](/badges/sergsxm-ui-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sergsxm-ui-bundle/health.svg)](https://phpackages.com/packages/sergsxm-ui-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.8k8.7k1](/packages/kimai-kimai)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k58](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
