Changeset 5948


Ignore:
Timestamp:
01/18/12 19:24:15 (4 months ago)
Author:
vain
Message:
  • setAttribute() will use a setterMethod in DEBUG mode to protect the developer
  • in live mode the attribute is assigned directly to the property
  • closes ticket #211
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/viewhelper/form/formelement.php

    r5934 r5948  
    416416            { 
    417417                /** 
    418                  * attributes are directly set 
    419                  * one might even set a wrong one by accident, like $attribute = 'maxxxlength' 
    420                  * protect the developer a little bit more here. 
    421                  * @todo check if attribute is allowed, lookup in whitelist 
    422                  * @todo protect formelement attr and use setters 
     418                 * In DEBUG mode the attributes are set via a setter method. 
     419                 * So one might even set a wrong one by accident, like $attribute = 'maxxxlength'. 
     420                 * To protect the developer a bit more, we are focing the usage of a setter method. 
     421                 * If the setter method exists most likely the property will exist too, i guess. 
    423422                 */ 
    424  
    425                 # set attribute directly 
    426                 $this->{$attribute} = $value; 
     423                if(DEBUG == true) 
     424                { 
     425                    $method = 'set' . $attribute; 
     426                    $this->{$method}($value); 
     427                } 
     428                else # while in production mode 
     429                { 
     430                    # set attribute directly 
     431                    $this->{$attribute} = $value; 
     432                } 
    427433            } 
    428434        } 
Note: See TracChangeset for help on using the changeset viewer.