Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use page tree view for forms #5423

Closed
havutcuoglu opened this issue Oct 25, 2022 · 13 comments
Closed

Use page tree view for forms #5423

havutcuoglu opened this issue Oct 25, 2022 · 13 comments
Labels

Comments

@havutcuoglu
Copy link

Description

The forms are displayed in alphabetical groups, one below the other. If you operate several websites within one installation, or have several forms within one installation, or have defined different languages and forms for a website, the display becomes confusing. Even renaming the forms by name does not help here.

For example, several websites in one installation:

  • website x contact form
  • website y contact form
  • website z contact form
  • and another 10 entries... and all this also for an application form.

Example for multi language website:

  • contact form en-EN
  • contact form en-UK
  • contact form de-DE
  • contact form de-CH
  • contact form de-AU
  • contact form zn
  • contact form tr
  • contact form az... and all this also for all the other forms.

Can we implement an option for forms like page view to display or move the forms below a directory?

forms

@aschempp
Copy link
Member

How does this apply to forms but not to anything else? How do you know which news archive belongs to which page etc? I think finding a naming convention that works for you would be the best solution …

@havutcuoglu
Copy link
Author

News archive to wich page?

We don't need any connection to pages or archives. Just a view option like page view or like a view by file management.
The user can create an ID as folder name, set the name by himself and move the forms there. The connection u need is only the user created name ID.

website EN as a directory - ID 1
|__ contact form EN
|__ application form EN
|__ offer form...

website DE as a directory - ID 2
|__ contact form DE
|__ application form DE
|__ offer form...

Naming convention will work as soon you don't have the same first letter for your form like your name conversion.

@fritzmg
Copy link
Contributor

fritzmg commented Oct 25, 2022

Forms are not associated with any parent thus there can be no tree view.

@havutcuoglu
Copy link
Author

OK. It is not nice at all. But if there is no other solution, that mean, we have to take care of the length of forms.
Maybe you can discuss it in your team meeting and find a solution?

@m-vo
Copy link
Member

m-vo commented Oct 25, 2022

Forms are not associated with any parent thus there can be no tree view.

I think the requested feature is displaying a list ordered by a dynamic prefix. Or call it a prefix tree, but it's purely for the view, not the data. IMHO an interesting idea, but as @aschempp pointed out this is not limited to forms at all.

Maybe you can discuss it in your team meeting and find a solution?

There is no easy solution for this. And it would involve cleaning up a lot of things first. So I think it's unlikely someone is going to do this in their free time. If we agree we want this and agree on a way this could be solved and you'll find someone that implements this, we would surely accept a PR. 😉

@asaage
Copy link

asaage commented Oct 25, 2022

One naming convention i use (and that can be also be seen in the screenshot above) is to add something in square-brackets to the name. Grouping by that would be nice but @m-vo was quicker than me. (it's a suffix though)

@fritzmg
Copy link
Contributor

fritzmg commented Oct 25, 2022

I think the requested feature is displaying a list ordered by a dynamic prefix. Or call it a prefix tree, but it's purely for the view, not the data.

That's already (sort of) possible with flag 3 and 4 - plus length: https://docs.contao.org/dev/reference/dca/fields/#reference

@havutcuoglu
Copy link
Author

havutcuoglu commented Oct 25, 2022

It is not possible to set a field in the tl_form as a flag so that one can decide whether the form is a real form or serves as a directory? Then you could implement the dependency with another field.

@fritzmg
Copy link
Contributor

fritzmg commented Oct 25, 2022

For example:

// contao/dca/tl_form.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;

$GLOBALS['TL_DCA']['tl_form']['fields']['groupTitle'] = [
    'label' => ['Group', 'Set a group title.'],
    'inputType' => 'text',
    'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
    'flag' => 3,
    'length' => 9999,
    'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
];

$GLOBALS['TL_DCA']['tl_form']['list']['sorting']['fields'] = ['groupTitle', 'title'];

PaletteManipulator::create()
    ->addField('groupTitle', 'title_legend', PaletteManipulator::POSITION_APPEND)
    ->applyToPalette('default', 'tl_form')
;

@fritzmg
Copy link
Contributor

fritzmg commented Oct 25, 2022

Or, if you want to group specifically by website roots:

// contao/dca/tl_form.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Contao\PageModel;

$GLOBALS['TL_DCA']['tl_form']['fields']['site'] = [
    'label' => ['Site', 'Choose a website root for grouping.'],
    'exclude' => true,
    'filter' => true,
    'inputType' => 'select',
    'foreignKey' => 'tl_page.title',
    'options_callback' => static function(): array {
        $sites = [];

        foreach (PageModel::findByType('root', ['order' => 'sorting ASC']) ?? [] as $root) {
            $sites[$root->id] = $root->title;
        }

        return $sites;
    },
    'eval' => ['tl_class' => 'w50', 'mandatory' => true],
    'flag' => 3,
    'length' => 9999,
    'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0],
];

$GLOBALS['TL_DCA']['tl_form']['list']['sorting']['fields'] = ['site', 'title'];

PaletteManipulator::create()
    ->addField('site', 'title_legend', PaletteManipulator::POSITION_APPEND)
    ->applyToPalette('default', 'tl_form')
;

@havutcuoglu
Copy link
Author

havutcuoglu commented Oct 25, 2022

OK. So it's possible. Can't you include that in core? Even grouping with website root is actually the best solution for me.
I like this solution: #5423 (comment)

@fritzmg
Copy link
Contributor

fritzmg commented Oct 25, 2022

Can't you include that in core?

No, it should not be included in the core as this is something that is individual to your Contao instance. As you can see you can take full advantage of Contao's customizability.

@leofeyer
Copy link
Member

Forms are not associated with any parent thus there can be no tree view.

That‘s right.

@leofeyer leofeyer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants