RenderWithError odd behaviour if CSS changed

thread: 3 messages  |  last: a year ago  |  started: tuesday, february 21, 2012, 1:07 am pst


#1  |  Mike Cobb United Kingdom
Tuesday, February 21, 2012, 1:07 AM PST

I have a form with the following TextBox control

$this->txtSkype = new QTextBox($this);
$this->txtSkype->CssClass = 'txt-lng-view';
$this->txtSkype->Name = 'Skype';
$this->txtSkype->Text = $this->objUser->Skype;

This controlled is rendered using RenderWithError

btnEdit_Click changes the CssClass of the TextBox
$this->txtSkype->CssClass = 'txt-lng-edit';

btnSave_Click saves the changes
$this->objUser->Skype = $this->txtSkype->Text;
$this->objUser->Save();

However the original $this->objUser->Skype value is saved not what the user has entered in $this->txtSkype->Text.

I have tried various permutations but still can't get the user entered value to save unless I remove the change to CssClass. Any clues as to what I'm missing.
Thanks
Mike

#2  |  Mike Cobb United Kingdom
Tuesday, February 21, 2012, 9:10 AM PST

I now have a similar problem if I don't change the CssClass but the user input text is cleared if it fails validation. If the user reenters valid text the validation continues to fail as their first input text is sent not the new text.
Mike

#3  |  Mike Cobb United Kingdom
Thursday, February 23, 2012, 3:07 PM PST

I hope this saves somebody a week of their lives!

The code below for some reason caused the problems I was having:

<body>
   <div id=“main-container”>            
       <div id=“top-panel”>
       <?php $this->RenderBegin(); ?>

To solve it required moving RenderBegin() to immediately below the body tag as follows:

<body>
   <?php $this->RenderBegin(); ?>
   <div id=“main-container”>            
      <div id=“top-panel”>

I don't confess to understand why but problem solved.
Mike



Copyright © 2005 - 2013, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.