We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41647
    • 49 Posts
    Hi!
    I wondered if someone could help me out here.
    I have a MIGX-TV with mupltiple formtabs.
    Each of these formtabs geneates a box (like a widget in other cms) for my sidebar.
    The problem is, that they all should have different templates.
    I know i could set the chunk with the "@FIELD:MIGX_formname" but I don't want to do it this way. (Doesn't look nice for the customer)
    So i thought of setting a hidden TV with a default value for each formtab.
    Worked fine, but sometimes the default value get overwritten by another, when changing the formtab with the dropdown.

    For example I have my formtabs-dropdown and "Downloads" is selected by default. Now i change to "Textbox" and this is what i get in html:

    <input type="hidden" id="tvdef53_6" value="textbox">
    <input id="tv53_6" name="tv53_6" type="hidden" value="downloadsbox">


    As you can see migx takes the value "downloadsbox" from the "Downloads"-formtab instead of using "textbox".

    Is there any way I can prevent this?
    Or any other possibility of setting a default template for each formtab I didn't think of?

    Thanks!

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      this should be possible with a special hidden-tv-type.
      I named it 'hidden_fixvalue' , code is nearly the same as for the hidden-TV:

      file core/model/modx/processors/element/tv/renders/mgr/input/hidden_fixvalue.class.php

      <?php
      /**
       * @package modx
       * @subpackage processors.element.tv.renders.mgr.input
       */
      class modTemplateVarInputRenderHiddenFixvalue extends modTemplateVarInputRender {
          public function getTemplate() {
              return 'element/tv/renders/input/hidden_fixvalue.tpl';
          }
      }
      return 'modTemplateVarInputRenderHiddenFixvalue';
      


      file manager/templates/default/element/tv/renders/input/hidden_fixvalue.tpl

      <input id="tv{$tv->id}" name="tv{$tv->id}" type="hidden" value="{$tv->get('default_text')|escape}"" />
      
      <script type="text/javascript">
      // <![CDATA[
      {literal}
      MODx.on('ready',function() {
          var fld = MODx.load({
          {/literal}
              xtype: 'hidden'
              ,applyTo: 'tv{$tv->id}'
              ,value: '{$tv->get('value')|escape:'javascript'}'
          {literal}
          });
          var p = Ext.getCmp('modx-panel-resource');
          if (p) {
              p.add(fld);
              p.doLayout();
          }
      });
      {/literal}
      // ]]>
      </script>
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 41647
        • 49 Posts
        Thanks Bruno!
        You really know your stuff - never had such a great support on a modx-package!