Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
unserialize not work in a view file
  • i use hmvc to visite a controller
    this controller render a view
    in view i use unserialize,but not work.
    $opt = $vi->field->options;
       
       if($opt){
        $opt = unserialize($opt);  print_r($opt);
        if(is_array($opt)){ 
         $rt = $opt['rt'];
         $rt_column = $opt['column']; 
         if($rt && $rt_column){
          $ret = 'r_'.$k; 
          echo $rt_column;
          $value = $post->$ret->$rt_column;
         }
        } 
       }
    
  • i check length is not right.
    is it ORM filter column?
    how can i do ?
  • i use this code to slove it.
    protected static $_observers = array( 
            'Orm\\Observer_Self' => array(
                'before_save',
                'after_load',
            ),
        );
        public function _event_before_save(){  
         if($this->rules)  
             $this->rules = json_encode($this->rules); 
        }
    
        public function _event_after_load(){  
            $this->rules = json_decode(json_decode($this->rules),true); 
        }
    
    may be not good
  • When you post a question, try to explain what you did, what you expected, what didn't work, and what the result was. I can't do much with "it doesn't work". But my guess is that when you pass data to a view, it gets escaped by default. If there is something in that string that requires escaping, the serialized array definition is no longer correct (as it contains field value lengths). So either unserialize it in the controller (if this is data from a database, unserialize it already in the model), or pass the data to the view unescaped (which is a potential security risk).
  • sorry, i slove it by myself.
    thank you

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion