VM2 -> VM3 customfield data encoding newline with 


Started by welrachid, December 21, 2014, 17:35:14 PM

Previous topic - Next topic

welrachid

Hello everyone
Im still working on converting VM2 custom plugin to VM3.
I have a textarea that is encoding a newline (the data consists of two lines) with 
 instead of \n. I guessing its a way for VM to write \r\n (keycode 13 is "return" in JS) - http://www.asquare.net/javascript/tests/KeyCode.html
My question is whether this is intentional or am i doing something wrong the place im using the data. [If this is intentionally i will repost this topic in an other category.]

In my function plgVmOnSelfCallFE($type,$name,&$render) which is called using a AJAX call after page load (it loads different amount/pricing options)
im using this to get the customfield data

      $product_obj = $model->getProduct($product_id,false);
      $wsy_nem_array = json_decode(json_encode($product_obj->customfields[0]->nem),true);
      $product_obj->customfields[0]->nem = $wsy_nem_array;

Right now im only rewriting code so that it works. Once it works ill be doing some code optimizations. (thats why u see me doing json_decode(json_encode())
Best regards,
Wel