[eluser]Eric Cope[/eluser]
I found a work around. I extended the Validation class.
Code:
function initializeFormElement($element,$val)
{
$this->$element = $val;
return TRUE; // I can add debug later
}
This still does not improve the set_select, but at least I can use the $this->validation->element to set the areas without an intermediary variable.
Digging around the Validation Class, I found how the set_select function works which confuses me. For completeness, here it is:
Code:
function set_select($field = '', $val)
{
if($field == '' OR $value == '' or !isset(_POST[$field]))
return '';
if($_POST[$field] == $val)
return ' selected="selected"';
}
Why are we comparing $_POST[$field]? That is an unclean variable. All clean variables are $this->validation->*. So, I made my own as below:
Code:
function set_select($field = '', $val)
{
if($field == '' OR $value == '' or !isset($this->$field))
return '';
if($this->$field == $val)
return ' selected="selected"';
}
That makes more sense to me. Maybe one of the Ellis Lab folks can fill us in on the decision to code the set_select in that manner, but my way seems to make more sense. What do you (the community) think?