Page 1 of 1

Setting the value field in an form text edit box with php

Posted: Sat Jan 04, 2014 3:11 pm
by ACBoon
Hello - I am trying to set the value field in a text edit box using a php call to a database. When I use the inspector entry for value, it converts the "<" and ">" to less than "&lt" and greater than "&gt" respectively in the published file (surely for html). Since I am trying to enter a php reference, I don't want this change, but cannot figure out how to escape it.

For reference, this does not appear to happen in the text area box. In this case, I can enter the value as I would like to see in the code and I get the entry directly as intended.

Help is much appreciated!

Re: Setting the value field in an form text edit box with ph

Posted: Sat Jan 04, 2014 3:33 pm
by Pablo
I'm sorry but all attributes will be encoded to make sure they do not causes errors in the generated code.

Re: Setting the value field in an form text edit box with ph

Posted: Sat Jan 04, 2014 4:07 pm
by ACBoon
Thanks for the quick reply. Is there a reason this happens in the text edit box value definition but not the text entry box value?

For others that may run into this issue, I can modify the published code to define my text edit box value to be what I want, but I then need to prevent publishing my page to be sure it is not over written.

Re: Setting the value field in an form text edit box with ph

Posted: Sat Jan 04, 2014 4:36 pm
by Pablo
The difference is the way these elements work in HTML
In an editbox the value is an attribute of the HTML element.
<input value="value">

In a textarea the value is put between the textarea tags.
<textarea>value</textarea>

Re: Setting the value field in an form text edit box with ph

Posted: Sat Jan 04, 2014 4:51 pm
by ACBoon
Got it...that makes sense. Thank you much. Very helpful.

Re: Setting the value field in an form text edit box with ph

Posted: Thu Jan 07, 2016 10:35 pm
by mauro
support wrote:I'm sorry but all attributes will be encoded to make sure they do not causes errors in the generated code.
I am a WYSIWYG user and all my wbesites use mysql database and most editboxes are filled in with

Code: Select all

<?php echo $var: ?>
I have switched to QuicknEasy and I am facing some difficulties due to this problem. I cannot use the texarea and if there is no resolution to my problem I will have to abandon QuicknEasy. What would you recommend to overcome this issue and why does it appear with QuicknEasy and not with WYSIWYG?

Re: Setting the value field in an form text edit box with ph

Posted: Fri Jan 08, 2016 7:26 am
by Pablo
To insert PHP code please use the HTML object or Page HTML.
Note that the text is intentionally encoded to make sure it does not break the HTML of the page.

Re: Setting the value field in an form text edit box with ph

Posted: Fri Jan 08, 2016 2:54 pm
by mauro
support wrote:To insert PHP code please use the HTML object or Page HTML.
Note that the text is intentionally encoded to make sure it does not break the HTML of the page.
Hi support, thanks for the quick reply. I have attached the image of the editbox html code. You advised me to use this option to insert php code and this is nothing new. But I need to replace the code inside the value tag and this is not possible from here. Maybe I didn’t well understand your advice, sorry. I need a solution to this problem and I need your help. As already requested why does QnE break the HTML code but WYSIWYG does not? Thank you!

Image

Re: Setting the value field in an form text edit box with ph

Posted: Fri Jan 08, 2016 6:24 pm
by Pablo
I have attached the image of the editbox html code.
This is correct. Values are encoded to make them valid.

Here's the W3C documentation about this process:
http://www.w3.org/International/questions/qa-escapes

This functionality was implemented based on user feedback.
You advised me to use this option to insert php code and this is nothing new.
No, I meant that you should use the 'HTML' object from the Toolbox.
As already requested why does QnE break the HTML code
The HTML is not broken! The editbox was not designed to contain PHP code.
The value of the editbox is intentionally encoded to make sure the resulting HTML is valid.

To use PHP code, please use an HTML object.

Re: Setting the value field in an form text edit box with ph

Posted: Fri Jan 08, 2016 7:57 pm
by mauro
support wrote: The HTML is not broken! The editbox was not designed to contain PHP code.
Sorry, I meant "break the HTML of the page". It would be a good idea to have an option to disable the encoding of all attributes.

support wrote: To insert PHP code please use the HTML object
If I have to use an html object to write a lot of editboxes and lose visual functionality I prefer to switch permanently to windows version where I can put PHP code in an edit box.
Thank you for your help and we will see in WYSIWYG web builder forum.

Re: Setting the value field in an form text edit box with ph

Posted: Fri Jan 08, 2016 8:59 pm
by Pablo
It would be a good idea to have an option to disable the encoding of all attributes.
I will take that into consideration.

Re: Setting the value field in an form text edit box with ph

Posted: Fri Jan 08, 2016 9:09 pm
by mauro
Great! I'm starting a new project and if you assure me that you will do it fast I will do it with QnE.

Re: Setting the value field in an form text edit box with php

Posted: Tue Mar 21, 2017 11:59 pm
by gregawal
I also had this problem for a few days ...
I wrote a shell script to do a post-process after the publish run to put back in the <%PHP tags
Use it as you see fit!!

#!/bin/bash
echo "Replacing the less than symbols ..."
grep -rl '&lt;?php' ./*.php | xargs sed -i 's/&lt;?php/<?php/g'
echo "Replacing the greater than symbols ..."
grep -rl '?&gt;' ./*.php | xargs sed -i 's/?&gt;/?>/g'
echo “Completed!”