We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    The input properties for this TV are not being set correctly in 2.2.2 (causing an unserialize error).
    They're exported directly from a working TV and I'm pretty sure this worked in 2.2.1.

    What's the correct format (and has it changed)?

    $templateVariables[6] = $modx->newObject('modTemplateVar');
    $templateVariables[6] ->fromArray(array(
        'id' => 6,
        'type' => 'text',
        'name' => 'nf_tags',
        'caption' => 'Tags',
        'description' => 'Comma-separated list of tags',
        'elements' => '',
        'rank' => '5',
        'display' => 'default',
        'default_text' => '',
        'properties' => '',
        'input_properties' => '{"allowBlank":"true","maxLength":"","minLength":""}',
        'output_properties' => '',
    ),'',true,true);


    [Update]

    The correct version appears to be:

    'input_properties' => 'a:3:{s:10:"allowBlank";s:4:"true";s:9:"maxLength";s:0:"";s:9:"minLength";s:0:"";}',


    or

    array(
       'allowBlank' => 'true',
       'maxLength' => '',
       'minLength' => '',
    );
    


    The incorrect version above was produced by this code:

    $properties = $tv->get('input_properties');
    $properties = empty($properties) ? '' : $modx->toJSON($properties);


    The correct JSON version comes from just using $tv->toArray(). I'm still curious about why the two methods produce different results. [ed. note: BobRay last edited this post 14 years, 4 months ago.]
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting