Populating data value for text input...

User 53435 Photo


Registered User
79 posts

I have a form container with a regular text input element.
Is there a way to populate the data value of the input element?
I'd like to add a PHP statement to the value attribute to display a pre-fetched value from a script.
eg:
value="<?php print $v ?>"
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Hi Geoff,
Yes you can use the method you posted but you have to make sure your server is setup to parse php inside html.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 53435 Photo


Registered User
79 posts

Except there does not appear to be anywhere to set the 'value' of the element in the Design panel.
Unless I am missing something?
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

No, you need to write your own scripts either php or JQuery. Another option is to set it after export.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 10077 Photo


Senior Advisor
1,096 posts

Geoff Swan wrote:
I have a form container with a regular text input element.
Is there a way to populate the data value of the input element?
I'd like to add a PHP statement to the value attribute to display a pre-fetched value from a script.
eg:
value="<?php print $v ?>"

The way that the WFB exported code works on the server is to read the html file containing the form into a variable (using file_get_contents). It is then "echoed" onto the page. Therefore, if you want to execute php within the form itself (such as to fill in value=""), you cannot use the WFB exported code snippet on your page.

Instead, you will need to export from WFB and alter the exported form. You then need to use the form code itself. You can still have it POST to the WFB processor, but you cannot use the code snippet provided by WFB at the time of export to display on the page. You have to manually put the form on your page.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/
User 53435 Photo


Registered User
79 posts

Brian Durfee wrote:
Geoff Swan wrote:
I have a form container with a regular text input element.
Is there a way to populate the data value of the input element?
I'd like to add a PHP statement to the value attribute to display a pre-fetched value from a script.
eg:
value="<?php print $v ?>"

The way that the WFB exported code works on the server is to read the html file containing the form into a variable (using file_get_contents). It is then "echoed" onto the page. Therefore, if you want to execute php within the form itself (such as to fill in value=""), you cannot use the WFB exported code snippet on your page.

Instead, you will need to export from WFB and alter the exported form. You then need to use the form code itself. You can still have it POST to the WFB processor, but you cannot use the code snippet provided by WFB at the time of export to display on the page. You have to manually put the form on your page.


I'm not using WFB at all. I build the forms using RSD (form container and elements) and then write a php script to handle it on submit (the action).
To display contents in the value field requires some editing after export from RSD to add the appropriate data population (using php from previously read values) to each form field value attribute. It works, but is messy because post-export editing is then required.
If the export included the ability to put something into 'value' then I could put the php block there and not have to edit later. Example <input value="<?php print $x ?>" ... />

However with the appropriate .htaccess file in place for the site the <?php /> contents in the .html file are evaluated through the php module in apache before being sent to the client.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.