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

element initial value #517

Open
2 tasks
user052 opened this issue May 18, 2020 · 1 comment
Open
2 tasks

element initial value #517

user052 opened this issue May 18, 2020 · 1 comment

Comments

@user052
Copy link

user052 commented May 18, 2020

Issue Overview

I am using Torro forms and trying to figure out how do I set a default value for a text field, and specifically for date field. I would like it to be initialized with the current date whenever the form opens. Could not find any documentation mentioning the issue.

Thanks in advance
D

Steps to Reproduce (for bugs)

Expected Behavior

Current Behavior

Possible Solution

Screenshots / Video

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
@sknopp
Copy link

sknopp commented May 23, 2020

You need to define a element template file under src/templates/element-yourelementname.php and define this behaviour by your PHP-code in there.
Therefore you can start by just copying the best matching template file from torro-forms to your plugin project or even better directly use element-date.php from plugin boilerplate and update it where needed.

E.g. you could check if $value has already been set and otherwise output the default value as field value.

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