We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21884
    • 57 Posts
    So i’m trying to use phx in my form to output a class if there’s an error message on submit, but it’s not working.

    here’s my code

    [[!FormIt? ]]
    <p id="validation">[[+fi.error.error_message]]</p>
    <form method="post" action="[[~[[*id]]]]">
    <p class="info">Fields marked with a <span class="required">*</span> are required.</p>
    <ul>
    	<li>
    		<label for="title">Title </label>
    		<select name="title"> 
    			<option value="" selected="selected"></option>
    			<option value="Mr" >Mr</option>
    			<option value="Mrs" >Mrs</option>
    			<option value="Miss" >Miss</option>
    			<option value="Dr" >Dr</option>
    		</select>
    	</li>
    	<li[[+fi.error.name:notempty=` class="error"`]]>
    		<label for="name">Name <span class="required">*</span></label>
    		<input type="text" name="name:required" value="[[+fi.name]]" />
    	</li>
    	<li[[+fi.error.house:notempty=` class="error"`]]>
    		<label for="House">House # <span class="required">*</span></label>
    		<input type="text" name="house:required" value="[[+fi.house]]" />
    	</li>
    	<li[[+fi.error.postcode:notempty=` class="error"`]]>
    		<label for="postcode">Postcode <span class="required">*</span></label>
    		<input type="text" name="postcode:required" value="[[+fi.postcode]]" />
    	</li>
    	<li>
    		<label for="tel">Telephone</label>
    		<input type="text" name="tel" value="[[+fi.tel]]" />
    	</li>
    	<li>
    		<label for="mobile">Mobile</label>
    		<input type="text" name="mobile" value="[[+fi.mobile]]" />
    	</li>
    	<li[[+fi.error.email:notempty=` class="error"`]]>
    		<label for="email">Email</label>
    		<input type="text" name="email:email" value="[[+fi.email]]" />
    	</li>
    	<li>
    		<label for="query-type">Sale/Let</label>
    		<select name="query-type">
    			<option value="" selected="selected"></option>
    			<option value="sale">Sale</option>
    			<option value="let">Let</option>
    		</select>
    	</li>
    	<li[[+fi.error.comments:notempty=` class="error"`]]>
    
    		<label for="comments">Comments</label>
    		<textarea name="comments:required:stripTags">[[+fi.comments]]</textarea>
    	</li>
    	<li>		
    		<input type="checkbox" name="financing" value="1" [[+fi.financing:notempty=`checked="checked"`]] />
    		<label for="financing">Financial advice requested</label>
    	</li>
    	<li>
    		<input type="submit" name="submit" value="Submit" />
    	</li>
    </ul>
    </form>


    i didn’t add anything to the formit call yet as i haven’t gotten that far. the form validates fine, but it seems like the phx calls aren’t working.

    do i need to add phx to my modx revolution install somewhere? i looked around and haven’t seen anything to indicate that it’s not included already in revo.
      • 12236
      • 48 Posts
      Digital Butter - MODX Premiere Partners Reply #2, 16 years, 4 months ago
      I think you could take a look at the ’If’ snippet, which will allow you to do conditionals like ’notempty’ and more:

      http://svn.modxcms.com/docs/display/ADDON/If

      There is some PHx style parsing in revolution (called input/output filters) but not all of the PHx functionality is in there. You may want to build your own output filters too - explained in the docs:

      http://svn.modxcms.com/docs/display/revolution/Input+and+Output+Filters
        • 21884
        • 57 Posts
        ok, tried that, but it doesn’t work either, new code:

        <p class="error">[+validationmessage+]</p>
        
        <h3 class="contact">Contact Us</h3>
         
        <form method="post" action="[~[*id*]~]" id="EmailForm">
        	<fieldset>
        		<p>** All fields are required **</p>
        		<input name="formid" type="hidden" value="ContactForm" />
        		<ul>
        		<li>
        			<label for="selector" id="dept">Who would you like to contact:</label>
        			<select name="selector" id="cfSelector" class="selBox" eform="Select Target::1:">
        				<option value="1">Contact</option>
        				<option value="2">Development</option>
        			</select>
        		</li>
        		<li>
        			<label for="name">Your name:</label>
        			<input name="name" id="cfName" class="text" type="text" eform="Name::1:" />
         		</li>
         		<li>
        			<label for="email">Your Email Address:</label>
        			<input name="email" id="cfEmail" class="text" type="text" eform="Email Address:email:1" />
         		</li>
        		<li>
        			<label for="subject">Subject:</label>
        			<input name="subject" id="cfRegarding" class="text" type="text" eform="Subject::1" />
          		</li>
        		<li>
        			<label for="message">Message:</label>
        			<textarea name="message" id="cfMessage" eform="Message:textarea:1"></textarea>
          		</li>
        		<li>
        			<input type="submit" name="contact" id="cfContact" class="button" value="Send" />
        		</li>
        		</ul>
        	</fieldset>
        </form>
          • 1778
          • 659 Posts
          Same problem here, input/output modifiers seem not work either on checkboxes and radio button...
            • 3749
            • 24,544 Posts
            I think the problem is that the PHX-like output modifiers only work in MODx tags and you don’t have any MODx tags in your code. FormIt processes its own modifiers (email, blank, etc.), but not the rest.
              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