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

Issues related to forms.
Post Reply
ACBoon
Posts: 3
Joined: Sat Jan 04, 2014 2:59 pm

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

Post by ACBoon » Sat Jan 04, 2014 3:11 pm

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!

User avatar
Pablo
Site Admin
Posts: 2505
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

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

Post by Pablo » Sat Jan 04, 2014 3:33 pm

I'm sorry but all attributes will be encoded to make sure they do not causes errors in the generated code.

ACBoon
Posts: 3
Joined: Sat Jan 04, 2014 2:59 pm

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

Post by ACBoon » Sat Jan 04, 2014 4:07 pm

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.

User avatar
Pablo
Site Admin
Posts: 2505
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

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

Post by Pablo » Sat Jan 04, 2014 4:36 pm

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>

ACBoon
Posts: 3
Joined: Sat Jan 04, 2014 2:59 pm

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

Post by ACBoon » Sat Jan 04, 2014 4:51 pm

Got it...that makes sense. Thank you much. Very helpful.

mauro
Posts: 9
Joined: Mon Jan 04, 2016 3:39 pm

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

Post by mauro » Thu Jan 07, 2016 10:35 pm

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?

User avatar
Pablo
Site Admin
Posts: 2505
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

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

Post by Pablo » Fri Jan 08, 2016 7:26 am

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.

mauro
Posts: 9
Joined: Mon Jan 04, 2016 3:39 pm

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

Post by mauro » Fri Jan 08, 2016 2:54 pm

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

User avatar
Pablo
Site Admin
Posts: 2505
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

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

Post by Pablo » Fri Jan 08, 2016 6:24 pm

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.

mauro
Posts: 9
Joined: Mon Jan 04, 2016 3:39 pm

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

Post by mauro » Fri Jan 08, 2016 7:57 pm

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.

User avatar
Pablo
Site Admin
Posts: 2505
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

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

Post by Pablo » Fri Jan 08, 2016 8:59 pm

It would be a good idea to have an option to disable the encoding of all attributes.
I will take that into consideration.

mauro
Posts: 9
Joined: Mon Jan 04, 2016 3:39 pm

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

Post by mauro » Fri Jan 08, 2016 9:09 pm

Great! I'm starting a new project and if you assure me that you will do it fast I will do it with QnE.

gregawal
Posts: 1
Joined: Tue Mar 21, 2017 12:18 am

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

Post by gregawal » Tue Mar 21, 2017 11:59 pm

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!”

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests