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

More information about default values of form fields #857

Open
modir opened this issue Oct 9, 2021 · 3 comments
Open

More information about default values of form fields #857

modir opened this issue Oct 9, 2021 · 3 comments

Comments

@modir
Copy link

modir commented Oct 9, 2021

It would be great if the page https://docs.contao.org/manual/de/formulargenerator/formularfelder/ would have more information about default values of form fields, Especially about dynamic default values. E.g. How can I set the current date as the default value. Or how can I set a GET parameter as a default value.

@fritzmg
Copy link
Contributor

fritzmg commented Oct 20, 2021

E.g. How can I set the current date as the default value. Or how can I set a GET parameter as a default value.

The recommended way in my opinion would be to use a loadFormField hook and then pre-fill the widget's value with whatever you need, while keeping security in mind.

I recently added this functionality to https://github.com/inspiredminds/contao-extended-form-fields though. With that extension installed you can enable a setting for each form field where its default value would be extracted from a query parameter of the same name.

@modir
Copy link
Author

modir commented Oct 20, 2021

Thank you Fritz. In the forums many write about another solution. That I would have to write something like {{GET:variableName}} into the default field. Hence I thought it would be great to have a better documentation about it. To have a solution is one thing. To have a better documentation another. And this issue here is now because of the documentation and not about finding a solution. But thanks again.

@fritzmg
Copy link
Contributor

fritzmg commented Oct 20, 2021

And this issue here is now because of the documentation and not about finding a solution.

I know ;). The ticket is not closed.

That I would have to write something like {{GET:variableName}} into the default field.

Probably something like {{file::get.php?…}}, but that's not very elegant and thus I would be reluctant to add that to the documentation as an official solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants