Show
Ignore:
Timestamp:
03/01/06 23:00:59 (6 years ago)
Author:
john
Message:

made auto_indexing work in helpers

Location:
trunk/trax/vendor/trax/action_view
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/action_view/helpers.php

    r152 r160  
    3939     */ 
    4040    function __construct($object_name = null, $attribute_name = null) { 
    41         $this->object_name = $object_name; 
     41        if(substr($object_name, -2) == "[]") { 
     42            $auto_index = true;              
     43        } 
     44        $this->auto_index = false; 
     45        $this->object_name = str_replace("[]", "", $object_name);      
    4246        $this->attribute_name = $attribute_name;         
    4347        $this->controller_name = $GLOBALS['current_controller_name']; 
    4448        $this->controller_path = $GLOBALS['current_controller_path']; 
    4549        $this->controller_object = $GLOBALS['current_controller_object']; 
     50        if($auto_index) { 
     51            $object = $this->object(); 
     52            if(is_object($object)) { 
     53                $index = $object->index_on; # should be primary key (usually id field) 
     54                $this->auto_index = $object->$index;     
     55            }   
     56        }          
    4657    } 
    4758 
  • trunk/trax/vendor/trax/action_view/helpers/form_helper.php

    r152 r160  
    7777     * 
    7878     */ 
    79     function add_default_name_and_id($options) { 
    80         if(array_key_exists("index", $options)) { 
     79    function add_default_name_and_id($options) {     
     80        if(array_key_exists("index", $options)) { 
    8181            $options["name"] = $options["name"] ? $options["name"] : $this->tag_name_with_index($options["index"]); 
    8282            $options["id"] = $options["id"] ? $options["id"] : $this->tag_id_with_index($options["index"]);