Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Default values on form

Started by xavi 9 years ago · 1 replies · 1301 views
9 years ago

Hi,

I have a created a form to gather user information. Now I have the information stored on the database, I want to fill the form with the information the user has provided. I am trying to do it with twig variables on the "default" attribute of the form, just like this:
name: user-name
default: {{ userNameFromDatabase }}

I have a plugin that handles the information recovery and assignment to the twig vars:
public function onMarkdownInitialized(Event $event)
{
$this->grav['twig']->twig_vars['userNameFromDatabase'] = 'John';
}

It doesn't display anything. I have modified the system.yaml, pages - frontmatter - process_twig to true, but nothing happens neither.

Is there a proper way to print a form fulfilled with the user information?

Thanks,
xavi

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 39 16 hours ago
General · by Hanns Mattes, 1 week ago
0 119 1 week ago
General · by Karmalakas, 1 week ago
2 184 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 234 3 weeks ago
General · by Dima, 4 weeks ago
1 210 4 weeks ago