We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40249
    • 31 Posts
    When i try to add the FormIt Chunk like this

    [[*layout_type:eq=`contact`:then=`[[$contact_form]]` ]]

    then the Formit Form isn't working propper. The form doesn't show up.

    when i just use the chunk like this without condition
    [[$contact_form]]

    the page gets rendered with the working form.

    the same code works fine on modx 2.2.9

    is this a bug or do i need to call the chunk in a different way?

    it also doesn't work when i add the chunk to a resource and load the content on condition.


    [ed. note: degoya last edited this post 10 years, 6 months ago.]
    • Try adding in the else portion of the conditional modifier.

      [[*layout_type:eq=`contact`:then=`[[$contact_form]]`:else=``]]
        Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
        Visit CharlesMx.com for latest news and status updates.
        • 40249
        • 31 Posts
        thanks but that doesn't solve the problem sad

        [[*layout_type:eq=`contact`:then=`true`:else=`false`]]


        works and gives correct output, so the condition works. when i use the chunk without condition it works aswell.

        here is the code of the chunk, but i get the same result when i take the example code from rtfm.
        [[!FormIt? &hooks=`email,redirect` &emailSubject=`Kontakt` &emailTpl=`Kontakt_Mail` &emailTo=`[email protected]` &redirectTo=`9` &validate=`Anrede:required, Name:required, E-Mail:email:required, Ihre_Nachricht:text:required:stripTags`]]
        			<form role="form" class="form-horizontal" id="myform" action="[[~[[*id]]? &scheme=`full`]]#myform" method="post" enctype="multipart/form-data">
        				<input type="hidden" name="nospam:blank" />[[+fi.validation_error_message:isnot=``:then=`<div class="alert alert-danger">[[%degoya.formErrorMsg? &language=`[[++cultureKey]]` &namespace=`degoya`]]</div><br /><br />`]]
        				<div class="form-group [[+fi.error.Anrede:isnot=``:then=`error`]]">
        					<label for="Anrede">[[%degoya.formTitle? &language=`[[++cultureKey]]` &namespace=`degoya`]]*</label>
        						<select class="form-control" id="Anrede" name="Anrede">
        						<option value="">[[%degoya.formPleaseSelect? &language=`[[++cultureKey]]` &namespace=`degoya`]]</option>
        						<option value="[[%degoya.formTitleOptionFemale? &language=`[[++cultureKey]]` &namespace=`degoya`]]">[[%degoya.formTitleOptionFemale? &language=`[[++cultureKey]]` &namespace=`degoya`]]</option>
        						<option value="[[%degoya.formTitleOptionMale? &language=`[[++cultureKey]]` &namespace=`degoya`]]">[[%degoya.formTitleOptionMale? &language=`[[++cultureKey]]` &namespace=`degoya`]]</option>
        						</select>
        				</div>
        				<div class="form-group [[+fi.error.Name:isnot=``:then=`error`]]" >
        					<label for="Name">[[%degoya.formName? &language=`[[++cultureKey]]` &namespace=`degoya`]]* </label> 
        					<input class="form-control" id="Name" type="text" name="Name" value="[[+fi.Name]]" />
        				</div>
        				<div class="form-group">
        					<label for="Telefon">[[%degoya.formPhone? &language=`[[++cultureKey]]` &namespace=`degoya`]]</label> 
        					<input class="form-control" id="Telefon" type="text" name="Telefon" value="[[+fi.Telefon]]" />
        				</div>
        				<div class="form-group [[+fi.error.E-Mail:isnot=``:then=`error`]]">
        					<label for="E-Mail">[[%degoya.formMail? &language=`[[++cultureKey]]` &namespace=`degoya`]]*</label> 
        					<input class="form-control" id="E-Mail" type="text" name="E-Mail" value="[[+fi.E-Mail]]" />
        				</div>
        				<div class="form-group [[+fi.error.Ihre_Nachricht:isnot=``:then=`error`]]">
        					<label for="Ihre_Nachricht">[[%degoya.formYourMessage? &language=`[[++cultureKey]]` &namespace=`degoya`]]*</label> 
        						<textarea class="form-control" id="Ihre_Nachricht" name="Ihre_Nachricht" rows="10" cols="50">[[+fi.Ihre_Nachricht]]</textarea><br /><br /><p>
        					<div class="alert alert-info">[[%degoya.formInfoRequired? &language=`[[++cultureKey]]` &namespace=`degoya`]]</div>
        					<br /> <button class="btn btn-custom pull-right" type="submit">[[%degoya.formBtnSend? &language=`[[++cultureKey]]` &namespace=`degoya`]] <i class="icon-envelope"></i></button>
        
        
        				</div>
        			</form>
        


        Including other chunks with conditions work aswell, the problem is only existent with formit





        • Does it work with [[!*layout_type....]] (! in front) ?

          Why doing so.. why not add a new template, put that form inside the place where you want to have it and change the template on the page where the that "type" eq. "contact" ??
            MODX Ambassador (NL) & Professional MODX developer
            Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
            MODX e-commerce solution SimpleCart
          • Tried it copy/pasted from your posts, and it works fine. I did make one modification to your modified TV tags:
            [[[[*layout_type:eq=`contact`:then=`$contact_form`]]]]
            

            http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

            I avoid nesting tags using output modifiers whenever possible, but out of curiosity I tried it exactly as you have it, with the tags nested, and in fact it didn't display! Interesting... [ed. note: sottwell last edited this post 10 years, 6 months ago.]
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 40249
              • 31 Posts
              Quote from: sottwell at Oct 16, 2013, 03:51 AM
              Tried it copy/pasted from your posts, and it works fine. I did make one modification to your modified TV tags:
              [[[[*layout_type:eq=`contact`:then=`$contact_form`]]]]
              

              http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/

              I avoid nesting tags using output modifiers whenever possible, but out of curiosity I tried it exactly as you have it, with the tags nested, and in fact it didn't display! Interesting...

              [[[[*layout_type:eq=`contact`:then=`$contact_form`]]]]
              


              thanks sottwell, your solution works now. it's too funny that the other code worked well in 2.2.9

              then i better start rethinking about my templates with alot of conditional stuff to speedup the site.