Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Adding a default value to "email_field" in volt?

Making my form as friendly as possible, I wish to repopulate it with the details entered by the user even when they got something wrong. In this case, I am using "emailfield" in volt to show a a field for email entry that will use initial validation by the browser when supported (Opera/Chrome but not Safari). I then server-side check the email address is both valid and not a common disposable address. However, "emailfield" and its php contemporary Phalcon::Tag::emailField do not respect passing in a "value" default, only "class". NOTE: I AM ASKING ABOUT VALUES NOT PLACEHOLDERS!

How can I achieve the equivalent of the following?:

{{ email_field("email","value":"somedefault") }}



174
Accepted
answer
edited May '15

I had the same problem, it seems this synthax is accepted by volt : {{ email_field({'email','value':"something"}) }}



425
edited May '15

That worked perfectly, many thanks.

To complete the thought for those who need it, this is the syntax for adding a default value and a class:

{{ email_field( { "email", "class" : "<someclass>", "value" : "<default value>" } ) }}



425

The plot thickens: This problem is now fixed in version 2.0.2.

You can return to

{{ email_field( "email", "class" : "<someclass>", "value" : "<default value>" ) }}

So you must take away the extra braces that were originally needed as a work around. This is much better, but it was annoying to go back and fix all my email fields!

thank topic. It's helpfull for me :)