This goes for version 7.01.0013 (possibly also for previous versions).
I have a grid with a date called DATE_FROM (see attachment 1)
This DATE_FROM is for storing a DATE type into a DATE field (see attachment 2).
The DATE_TO is a similar field, just another name.
On this field I have an Ajax Event
DATE_FROM_OnChange:
//the begin date must be <= end date
//sc_ajax_message('DATE_FROM_OnChange:'.{DATE_FROM}.' '.{DATE_TO},'Message');
if (!is_null({DATE_FROM}) && !is_null({DATE_TO})){
//datetime is a string in the yyyy-mm-dd formaat if I echo it
if ({DATE_FROM}>{DATE_TO})
sc_error_message('the begin date is past the end date. This is invalid');
}
When I show my grid and change the value in my DATE_FROM then even tho DATE_FROM<DATE_TO it still generates the sc_error_message!!!
When I use the following code (so with the red { and } ):
//the begin date must be <= end date
//sc_ajax_message('DATE_FROM_OnChange:'.{DATE_FROM}.' '.{DATE_TO},'Message');
if (!is_null({DATE_FROM}) && !is_null({DATE_TO})){
//datetime is a string in the yyyy-mm-dd formaat if I echo it
if ({DATE_FROM}>{DATE_TO}){
sc_error_message('the begin date is past the end date. This is invalid');
}
}
then it works fine!
When I view the generated code from the first one (with the red { and } ) on line 4715 then I get:
if (!is_null($this->date_from_ ) && !is_null($this->date_to_ )){
if ($this->date_from_ >$this->date_to_ )
if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'de begindatum ligt na de einddatum, dit is onjuist';
if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6))
{
$sErrorIndex = ('submit_form' == $this->NM_ajax_opcao) ? 'geral_grid_delegate' : substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
$this->NM_ajax_info['errList'][$sErrorIndex][] = 'de begindatum ligt na de einddatum, dit is onjuist';
}
;
}
When I do this for the second one I get:
if (!is_null($this->date_from_ ) && !is_null($this->date_to_ )){
if ($this->date_from_ >$this->date_to_ ){
if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'de begindatum ligt na de einddatum, dit is onjuist';
if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6))
{
$sErrorIndex = ('submit_form' == $this->NM_ajax_opcao) ? 'geral_grid_delegate' : substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
$this->NM_ajax_info['errList'][$sErrorIndex][] = 'de begindatum ligt na de einddatum, dit is onjuist';
}
;
}
}
The bug is in the code generator it should produce both code that works the same but IT DOES NOT!!
if ($this->date_from_ >$this->date_to_ )
if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = “”;}
…
is VERY DIFFERENT FROM
if ($this->date_from_ >$this->date_to_ ){
if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = “”;}
Please fix this bug asap.
If needed I can give a full detailed movie of this error.
How to avoid it? (for now).
In php we are allowed to do this:
if (condition)
statement;
To avoid the error to occur we must always do:
if (condition){
statement;
}
Annoying but true. It can cause strange unexpected behaviour if you do not do it that way…