edit live removing input from code view

Hello,

we have issues with putting this code into the code view of edit live in our content type. When we input the code and click update it just removes all the code and reverts back to what was saved before. We have however confirmed that the text area can be edited by inserting test data and updating

Thanks

Nicholas


<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/dynamic/gpi/validationclasses/validation.class.php');?>
     <h3>
         This page has been created for direct complaints regarding Gloucestershire Constabulary.
      </h3>
      <p>
         <strong>- please do not fill in this form in relation to other UK forces (or overseas) as this will not be dealt with by Gloucestershire.</strong>
      </p>
<div class="container">
   <div class="form-holder">

    <form action="/dynamic/gpi/complaints/index.php" method="post" class="new-form">

        <input name="form" value="<?php print $_SERVER['PHP_SELF']; ?>" type="hidden" />
<input type="hidden" name="formname" value="complaintsform" />
<input name="recipient" value="professionalstandardsdepartment@gloucestershire.police.uk;viv.house@gloucestershire.police.uk" type="hidden" />
     <div class="tr"></div>
     <div class="tl"></div>
     <div class="t"></div>
     <div class="borders">
              <fieldset>
       <legend>
       Complaints Form
       </legend>
       <ul>
	   <li>
	   <?php $selectValue = Validation::returnFormElementInput('Title');?>
            <label for="Title">Title</label><select name="Title" id="Title">
              <option value="No title selected" <?php if ($selectValue == "No title selected") echo 'selected="selected"' ;?>>
                - Select -
              </option>
              <option value="Mr" <?php if ($selectValue == "Mr") echo 'selected="selected"' ;?>>
                Mr
              </option>
              <option value="Mrs" <?php if ($selectValue == "Mrs") echo 'selected="selected"' ;?>>
                Mrs
              </option>
              <option value="Miss" <?php if ($selectValue == "Miss") echo 'selected="selected"' ;?>>
                Miss
              </option>
              <option value="Ms" <?php if ($selectValue == "Ms") echo 'selected="selected"' ;?>>
                Ms
              </option>
              <option value="Other" <?php if ($selectValue == "Other") echo 'selected="selected"' ;?>>
                Other
              </option>
            </select>
            
          </li>
           <?php validation::printError('Surname-error')?>
          <li>
            <label for="Surname">Surname</label> <input name="Surname" type="text" id="Surname" size="40" value="<?php Validation::retrieveFormElementInput('Surname')?>" />
       
          </li>
          <?php validation::printError('Forenames-error')?>
          <li>
            <label for="Forenames">Forename(s)</label> <input name="Forenames" id="Forenames" type="text" size="40"  value="<?php Validation::retrieveFormElementInput('Forenames')?>" />
          </li>
          <?php validation::printError('Previous_surname-error')?>
          <li>
            <label for="Previous_surname">Previous surname</label> <input name="Previous_surname" id="Previous_surname" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Previous_surname')?>" />
          </li>
          <?php validation::printError('Address-error')?>
          <li>
            <label for="Address">Address</label> 
<textarea name="Address" id="Address" cols="60" rows="4"><?php Validation::retrieveFormElementInput('Address')?>
</textarea>
          </li>
          <?php validation::printError('Postcode-error')?>
          <li>
            <label for="Postcode">Postcode</label> <input name="Postcode" id="Postcode" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Postcode')?>" />
          </li>
          <?php validation::printError('Date_of_birth-error')?>
          <li>
            <label for="Date_of_birth">Date of birth</label> <input name="Date_of_birth" id="Date_of_birth" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Date_of_birth')?>" />
          </li>
          <?php validation::printError('Place_of_birth-error')?>
          <li>
            <label for="Place_of_birth">Place of birth</label> <input name="Place_of_birth" id="Place_of_birth" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Place_of_birth')?>" />
          </li>
          <li>
            <label for="Gender">Gender</label> Male - <input name="Gender" id="Gender" value="Male" type="radio" />Female - <input name="Gender" id="Gender" value="Female" type="radio" checked="checked" />
          </li>
          <li>
          <?php $selectValue =  Validation::returnFormElementInput('Ethnicity');?>
            <label for="Ethnicity">Ethnicity</label> <select name="Ethnicity" id="Ethnicity">
              <option value="No ethnicity selected" <?php if ($selectValue == "No ethnicity selected") echo 'selected="selected"' ;?>>
                - Select -
              </option>
              <option value="Asian - Indian" <?php if ($selectValue == "Asian - Indian") echo 'selected="selected"' ;?>>
                Asian - Indian
              </option>
              <option value="Asian - Pakistani" <?php if ($selectValue == "Asian - Pakistani") echo 'selected="selected"' ;?>>
                Asian - Pakistani
              </option>
              <option value="Asian - Bangladeshi" <?php if ($selectValue == "Asian - Bangladeshi") echo 'selected="selected"' ;?>>
                Asian - Bangladeshi
              </option>
              <option value="Any Other Asian Background" <?php if ($selectValue == "Any Other Asian Background") echo 'selected="selected"' ;?>>
                Any Other Asian Background
              </option>
              <option value="Black Caribbean" <?php if ($selectValue == "Black Caribbean") echo 'selected="selected"' ;?>>
                Black Caribbean
              </option>
              <option value="Black African" <?php if ($selectValue == "Black African") echo 'selected="selected"' ;?>>
                Black African
              </option>
              <option value="Any Other Black Background" <?php if ($selectValue == "Any Other Black Background") echo 'selected="selected"' ;?>>
                Any Other Black Background
              </option>
              <option value="White & Black Caribbean" <?php if ($selectValue == "White & Black Caribbean") echo 'selected="selected"' ;?>>
                White & Black Caribbean
              </option>
              <option value="White & Black African" <?php if ($selectValue == "White & Black African") echo 'selected="selected"' ;?>>
                White & Black African
              </option>
              <option value="White & Asian" <?php if ($selectValue == "White & Asian") echo 'selected="selected"' ;?>>
                White & Asian
              </option>
              <option value="Any Other Mixed Background" <?php if ($selectValue == "Any Other Mixed Background") echo 'selected="selected"' ;?>>
                Any Other Mixed Background
              </option>
              <option value="Chinese" <?php if ($selectValue == "Chinese") echo 'selected="selected"' ;?>>
                Chinese
              </option>
              <option value="Any Other Ethnic Group" <?php if ($selectValue == "Any Other Ethnic Group") echo 'selected="selected"' ;?>>
                Any Other Ethnic Group
              </option>
              <option value="White British" <?php if ($selectValue == "White British") echo 'selected="selected"' ;?>>
                White British
              </option>
              <option value="White Irish" <?php if ($selectValue == "White Irish") echo 'selected="selected"' ;?>>
                White Irish
              </option>
              <option value="Any Other White Background" <?php if ($selectValue == "Any Other White Background") echo 'selected="selected"' ;?>>
                Any Other White Background
              </option>
            </select>
          </li>
          <?php validation::printError('Contact_telephone-error')?>
          <li>
            <label for="Contact_telephone">Contact telephone</label> <input name="Contact_telephone" id="Contact_telephone" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Contact_telephone')?>" />
          </li>
          <?php validation::printError('email-error')?>
          <li>
            <label for="email">Email</label> <input name="email" id="email" type="text" size="40" value="<?php Validation::retrieveFormElementInput('email')?>" />
          </li>
          
          <li>
          <?php $selectValue =  Validation::returnFormElementInput('Occupation');?>
            <label for="Occupation">Occupation</label> <select name="Occupation" id="Occupation">
              <option value="No_occupation_selected" <?php if ($selectValue == "No_occupation_selected") echo 'selected="selected"' ;?>>
                - Select -
              </option>
              <option value="Student" <?php if ($selectValue == "Student") echo 'selected="selected"' ;?>>
                Student
              </option>
              <option value="Homemaker" <?php if ($selectValue == "Homemaker") echo 'selected="selected"' ;?>>
                Homemaker
              </option>
              <option value="Unemployed" <?php if ($selectValue == "Unemployed") echo 'selected="selected"' ;?>>
                Unemployed
              </option>
              <option value="Retired" <?php if ($selectValue == "Retired") echo 'selected="selected"' ;?>>
                Retired
              </option>
              <option value="Manual" <?php if ($selectValue == "Manual") echo 'selected="selected"' ;?>>
                Manual
              </option>
              <option value="Non-manual" <?php if ($selectValue == "Non-manual") echo 'selected="selected"' ;?>>
                Non-manual
              </option>
              <option value="Unknown" <?php if ($selectValue == "Unknown") echo 'selected="selected"' ;?>>
                Unknown
              </option>
            </select>
          </li>
          <?php validation::printError('Date_of_incident-error')?>
          <li>
            <label for="Date_of_incident">Date of incident</label> 
            <input name="Date_of_incident" id="Date_of_incident" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Date_of_incident')?>" />
          </li>
          <?php validation::printError('Time_of_incident-error')?>
          <li>
            <label for="Time_of_incident">Time of incident</label> 
            <input name="Time_of_incident" id="Time_of_incident" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Time_of_incident')?>" />
          </li>
          <?php validation::printError('Incident_number-error')?>
          <li>
            <label for="Incident_number">Incident number (if known)</label> 
            <input name="Incident_number" id="Incident_number" type="text" size="40" value="<?php Validation::retrieveFormElementInput('Incident_number')?>" />
          </li>
          <?php validation::printError('Complaint_details-error')?>
          <li>
            <label for="Complaint_details">Please give details of your complaint</label> 
<textarea name="Complaint_details" id="Complaint_details" cols="60" rows="12"><?php Validation::retrieveFormElementInput('Complaint_details')?>
</textarea>
          </li>
          <?php validation::printError('Injury_details-error')?>
          <li>
            <label for="Injury_details">Please give details of injuries (if any)</label> 
<textarea name="Injury_details" id="Injury_details" cols="60" rows="8"><?php Validation::retrieveFormElementInput('Injury_details')?>
</textarea>
          </li>
          <?php validation::printError('Police_members-error')?>
          <li>
            <label for="Police_members">Members of the police service subject of complaint (please insert the identity of the individula(s) you wish to complain about, if known)</label> 
<textarea name="Police_members" id="Police_members" cols="60" rows="8"><?php Validation::retrieveFormElementInput('Police_members')?>
</textarea>
          </li>
          <li>
            <label class="hidden" for="submit">Submit</label><button type="submit" id="submit" name="submit" value="submit">Submit Form</button>
          </li>
		    </ul>
      </fieldset>
     </div>
     <div class="br"></div>
     <div class="bl"></div>

     <div class="b"></div>

    </form>
   </div>
  </div>

I believe Ephox EditLive has issues with embedding PHP (or similar code) into its fields (someone else mentioned this once before).

To add forms/complex HTML into pages the options I’ve normally gone for are:

  1. put the code into the velocity template in the workbench, maybe having to create a new template for this form
  2. having a ‘code’ content type which simply has a textarea (as opposed to EditLive) where you’ll put your PHP code. A simple snippet template would then be created called something like snCodeOnly which just outputs the textarea field. You then add a snippet of your code content item to a slot on the content item where you want the form.

Although the second option seems like you’re jumping through hoops a little, it separates complex code out to a more manageable content type, which can be restricted to certain users (ie., administrators - those people who are allowed to write code) and can stop content authors being exposed to scary/complex PHP code when editing content.

Thanks for the prompt reply David

We have set up our Ephox editor to only show the code tab for select groups of admins to prevent others from writing code but we are also having trouble using this feature for our needs. I would really like to continue using the Ephox editor because everyone seems to like the pop-out feature that allows them to re-size the input box to their needs, hopefully one day we can look into code completion possibilities.

A recent problem we found was that the Ephox editor was adding in CDATA tags into the code when it was updated, which broke the code when it was published to the web server.

*all code below has the < character replaced with a {.

Code added into Ephox:


{div id="cse-search-results"> {/div>
{p> {script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "erausearch";
var googleSearchFrameWidth = 670;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
{/script>
{script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js" />
{/p>
{/div>

Was replaced with then when the item was edited:


{div class="rxbodyfield">
{div id="cse-search-results"> {/div>
{p> {script type="text/javascript">[B]{![CDATA[[/B]
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "erausearch";
var googleSearchFrameWidth = 670;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
[B]]]>[/B]{/script>
{script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js">[B]{![CDATA[
                                       {\/script >{http://www.google.com/afsonline/show_afs_search.js>
                                       ]]>{/script>[/B]
{/p>
{/div>

*Notice the CDATA tags added by Ephox.

Which caused the page source to render like this:


{div id="cse-search-results"> {/div>
{p> {script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "erausearch";
var googleSearchFrameWidth = 670;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
{/script>
{script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js">[B](and sign)lt;\/script >(and sign)lt;[/B]http://www.google.com/afsonline/show_afs_search.js>
                                       {/script>
{/p>
{/div>

*Notice the html code for less than symbols, (replaced & sign).