We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27708 MODX Staff
    • 2,502 Posts
    I have started working on a custom comments form and output. Once I got the custom field working the name and email no longer seem to get stored in the DB or return. The custom field is "url" and I have added the &customfields to the call and included url, name, email as well as adding it to the form and the output as it seems it should.

    Please let me know what I am doing wrong. The output currently has broken fields in it but this should have no bearing on the fact that the name and email are not being stored to the db.

    Update: The solution is that the &customfields comma separated list MUST not contain spaces or it will only save data from the first item in the list. i.e., `name,email,url` and NOT `name, email, url` .

    Jot Version: 1.1.4
    MODx Version: 0.9.6.3 RC2

    Here is the Jot Call:
    [!Jot? &tplComments=`commentOutput` &tplForm=`commentForm` &customfields=`url, name, email` &debug=`1` !]


    Here is the Custom Form:
    <a name="jf[+jot.link.id+]"></a>
    <h2>[+form.edit:is=`1`:then=`Edit comment`:else=`Write a comment`+]</h2>
    <div class="jot-list">
    <ul>
    	<li>Required fields are marked with <b>*</b>.</li>
    </ul>
    </div>
    [+form.error:isnt=`0`:then=`
    <div class="jot-err">
    [+form.error:select=`
    &-3=You are trying to re-submit the same post. You have probably clicked the submit button more than once.
    &-2=Your comment has been rejected.
    &-1=Your comment has been saved, it will first be reviewed before it is published.
    &1=You are trying to re-submit the same post. You have probably clicked the submit button more than once.
    &2=The security code you entered was incorrect.
    &3=You can only post once each [+jot.postdelay+] seconds.
    &4=Your comment has been rejected.
    &5=[+form.errormsg:ifempty=`You didn't enter all the required fields`+]
    `+]
    </div>
    `:strip+]
    [+form.confirm:isnt=`0`:then=`
    <div class="jot-cfm">
    [+form.confirm:select=`
    &1=Your comment has been published.
    &2=Your comment has been saved, it will first be reviewed before it is published.
    &3=Comment saved.
    `+]
    </div>
    `:strip+]
    <form method="post" action="[+form.action:esc+]#jf[+jot.link.id+]" class="jot-form">
    	<fieldset>
    	<input name="JotForm" type="hidden" value="[+jot.id+]" />
    	<input name="JotNow" type="hidden" value="[+jot.seed+]" />
    	<input name="parent" type="hidden" value="[+form.field.parent+]" />
    	
    	[+form.moderation:is=`1`:then=`
    		<div class="jot-row">
    			<b>Created on:</b> [+form.field.createdon:date=`%a %B %d, %Y at %H:%M`+]<br />
    			<b>Created by:</b> [+form.field.createdby:userinfo=`username`:ifempty=`[+jot.guestname+]`+]<br />
    			<b>IP address:</b> [+form.field.secip+]<br />
    			<b>Published:</b> [+form.field.published:select=`0=No&1=Yes`+]<br />
    			[+form.field.publishedon:gt=`0`:then=`
    				<b>Published on:</b> [+form.field.publishedon:date=`%a %B %d, %Y at %H:%M`+]<br />
    				<b>Published by:</b> [+form.field.publishedby:userinfo=`username`:ifempty=` - `+]<br />
    			`+]
    			[+form.field.editedon:gt=`0`:then=`
    				<b>Edited on:</b> [+form.field.editedon:date=`%a %B %d, %Y at %H:%M`+]<br />
    				<b>Edited by:</b> [+form.field.editedby:userinfo=`username`:ifempty=` -`+]<br />
    			`+]
    		</div>
    	`:strip+]
    	
    	[+form.guest:is=`1`:then=`
    		<label for="name[+jot.id+]">Name:<br />
    		<input tabindex="[+jot.seed:math=`?+1`+]" name="name" type="text" size="40" value="[+form.field.custom.name:esc+]" id="name[+jot.id+]" />
    		</label>
    		<label for="email[+jot.id+]">Email:<br />
    		<input tabindex="[+jot.seed:math=`?+2`+]" name="email" type="text" size="40" value="[+form.field.custom.email:esc+]" id="email[+jot.id+]" />
    		</label>
                    <label for="url[+jot.id+]">Website:<br />
    		<input  tabindex="[+jot.seed:math=`?+3`+]" name="url" type="text" size="40" value="[+form.field.custom.url:esc+]" id="url[+jot.id+]" />
    		</label>
    	`+]
    	
    	<label for="title[+jot.id+]">Subject:<br />
    	<input tabindex="[+jot.seed:math=`?+4`+]" name="title" type="text" size="40" value="[+form.field.title:esc+]" id="title[+jot.id+]"/>
    	</label>
    	<label for="content[+jot.id+]">Comment: *<br />
    	<textarea tabindex="[+jot.seed:math=`?+5`+]" name="content" cols="50" rows="8" id="content[+jot.id+]">[+form.field.content:esc+]</textarea>
    	</label><br />
    	
      [+jot.captcha:is=`1`:then=`
    		<div style="width:150px;margin-top: 5px;margin-bottom: 5px;"><a href="[+jot.link.current:esc+]"><img src="[(base_url)]manager/includes/veriword.php?rand=[+jot.seed+]" width="148" height="60" alt="If you have trouble reading the code, click on the code itself to generate a new random code." style="border: 1px solid #003399" /></a></div>
    		<label for="vericode[+jot.id+]">Help prevent spam - enter security code above:<br /><input type="text" name="vericode" style="width:150px;" size="20" id="vericode[+jot.id+]" /></label> 
    	`:strip+]
    	
    	<div style="float:right;width: 100px;"></div>
    	<input tabindex="[+jot.seed:math=`?+6`+]" name="submit" type="submit" value="[+form.edit:is=`1`:then=`Save Comment`:else=`Post Comment`+]" />
    	[+form.edit:is=`1`:then=`
    		<input tabindex="[+jot.seed:math=`?+7`+]" name="submit" type="submit" value="Cancel" onclick="history.go(-1);return false;" />
    	`+] 
    	</fieldset>
    </form>


    Here is the Custom Output:
    	<a name="jc[+jot.link.id+][+comment.id+]"></a>
    	<div class="jot-row [+chunk.rowclass+] [+comment.published:is=`0`:then=`jot-row-up`+]">
    	 <div class="jot-comment">
     		 
    		 <div class="jot-user">
    		 [+comment.createdby:isnt=`0`:then=`<b>`+][+comment.createdby:userinfo=`username`:ifempty=`[+comment.custom.url:ne=``:then=`<a href="[+comment.custom.url+]">`+][+comment.custom.name:ifempty=`[+jot.guestname+]`:esc+][+comment.custom.url:ne=``:then=`</a>``+][+comment.createdby:isnt=`0`:then=`</b>`+]
    		 <br />Posts: [+comment.userpostcount+]
    <br />
    [+comment.custom.name:ifempty=`[+jot.guestname+]`:esc+]<br />
    [+comment.custom.url:ne=``:then=`<a href="[+comment.custom.url+]">`+][+comment.custom.name:ifempty=`[+jot.guestname+]`:esc+][+comment.custom.url:ne=``:then=`</a>`+]
    <br />
    
    <a href="[+comment.custom.url:esc+]"></a>
    		 </div> 
    		
    		 <div class="jot-content">
    			 
    			 <div class="jot-posticon">
    					[+phx:userinfo=`lastlogin`:ifempty=`9999999999`:lt=`[+comment.createdon+]`:then=`
    				 <img src="[(base_url)]manager/media/style/MODx/images/icons/folder_page_add.gif" width="18" height="18" alt="New comment" border="0" />
    				 `:else=`
    				 <img src="[(base_url)]manager/media/style/MODx/images/icons/newdoc.gif" width="16" height="16" alt="Comment" border="0" />
    				 `:strip+]
    			 </div>		 
    			 
    			 <div class="jot-mod">
    			 [+jot.moderation.enabled:is=`1`:then=`
    				<a href="[+jot.link.delete:esc+][+jot.querykey.id+]=[+comment.id+]#jotmod[+jot.link.id+]" onclick="return confirm('Are you sure you wish to delete this comment?')" title="Delete Comment"><img src="[(base_url)]manager/media/style/MODx/images/icons/event3.gif" width="16" height="16" alt="Delete Comment" border="0" /></a>
    				[+comment.published:is=`0`:then=`
    				<a href="[+jot.link.publish:esc+][+jot.querykey.id+]=[+comment.id+]#jotmod[+jot.link.id+]" onclick="return confirm('Are you sure you wish to publish this comment?')" title="Publish Comment"><img src="[(base_url)]manager/media/style/MODx/images/icons/add.png" width="16" height="16" alt="Publish Comment" border="0" /></a>
    				`+]
    				[+comment.published:is=`1`:then=`
    				<a href="[+jot.link.unpublish:esc+][+jot.querykey.id+]=[+comment.id+]#jotmod[+jot.link.id+]" onclick="return confirm('Are you sure you wish to unpublish this comment?')" title="Unpublish Comment"><img src="[(base_url)]manager/media/style/MODx/images/icons/delete.png" width="16" height="16" alt="Unpublish Comment" border="0" /></a>
    				`+]
    			 `:strip+]
    			 [+jot.user.canedit:is=`1`:and:if=`[+comment.createdby+]`:is=`[+jot.user.id+]`:or:if=`[+jot.moderation.enabled+]`:is=`1`:then=`
    				 <a href="[+jot.link.edit:esc+][+jot.querykey.id+]=[+comment.id+]#jf[+jot.link.id+]" onclick="return confirm('Are you sure you wish to edit this comment?')" title="Edit Comment"><img src="[(base_url)]manager/media/style/MODx/images/icons/logging.gif" width="16" height="16" alt="Edit Comment" border="0" /></a>
       		 `:strip+]
    			 </div>	
    			  
    			 <span class="jot-subject">[+comment.title:limit:esc+]</span><br />
    			 <span class="jot-poster"><b>Reply #[+comment.postnumber+] on :</b> [+comment.createdon:date=`%a %B %d, %Y, %H:%M:%S`+]</span>
    			 <hr />
    			 <div class="jot-message">[+comment.content:wordwrap:esc:nl2br+]</div>
    			 <div class="jot-extra">
    			 [+comment.editedon:isnt=`0`:then=`
    			  <span class="jot-editby">Last Edit: [+comment.editedon:date=`%B %d, %Y, %H:%M:%S`+] by [+comment.editedby:userinfo=`username`:ifempty=` * `+]</span>
    			   `+] [+jot.moderation.enabled:is=`1`:then=`<a target="_blank" href="http://www.ripe.net/perl/whois?searchtext=[+comment.secip+]">[+comment.secip+]</a>`+]</div>
    		 </div>
    		 
    	 </div>
    	
    	</div>
      Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
      • 20413
      • 2,877 Posts
      Try this:


      <a name="jf[+jot.link.id+]"></a>
      <h2>[+form.edit:is=`1`:then=`Edit comment`:else=`Write a comment`+]</h2>
      <div class="jot-list">
      <ul>
      	<li>Required fields are marked with <b>*</b>.</li>
      </ul>
      </div>
      [+form.error:isnt=`0`:then=`
      <div class="jot-err">
      [+form.error:select=`
      &-3=You are trying to re-submit the same post. You have probably clicked the submit button more than once.
      &-2=Your comment has been rejected.
      &-1=Your comment has been saved, it will first be reviewed before it is published.
      &1=You are trying to re-submit the same post. You have probably clicked the submit button more than once.
      &2=The security code you entered was incorrect.
      &3=You can only post once each [+jot.postdelay+] seconds.
      &4=Your comment has been rejected.
      &5=[+form.errormsg:ifempty=`You didn't enter all the required fields`+]
      `+]
      </div>
      `:strip+]
      [+form.confirm:isnt=`0`:then=`
      <div class="jot-cfm">
      [+form.confirm:select=`
      &1=Your comment has been published.
      &2=Your comment has been saved, it will first be reviewed before it is published.
      &3=Comment saved.
      `+]
      </div>
      `:strip+]
      <form method="post" action="[+form.action:esc+]#jf[+jot.link.id+]" class="jot-form">
      	<fieldset>
      	<input name="JotForm" type="hidden" value="[+jot.id+]" />
      	<input name="JotNow" type="hidden" value="[+jot.seed+]" />
      	<input name="parent" type="hidden" value="[+form.field.parent+]" />
      	
      	[+form.moderation:is=`1`:then=`
      		<div class="jot-row">
      			<b>Created on:</b> [+form.field.createdon:date=`%a %B %d, %Y at %H:%M`+]<br />
      			<b>Created by:</b> [+form.field.createdby:userinfo=`username`:ifempty=`[+jot.guestname+]`+]<br />
      			<b>IP address:</b> [+form.field.secip+]<br />
      			<b>Published:</b> [+form.field.published:select=`0=No&1=Yes`+]<br />
      			[+form.field.publishedon:gt=`0`:then=`
      				<b>Published on:</b> [+form.field.publishedon:date=`%a %B %d, %Y at %H:%M`+]<br />
      				<b>Published by:</b> [+form.field.publishedby:userinfo=`username`:ifempty=` - `+]<br />
      			`+]
      			[+form.field.editedon:gt=`0`:then=`
      				<b>Edited on:</b> [+form.field.editedon:date=`%a %B %d, %Y at %H:%M`+]<br />
      				<b>Edited by:</b> [+form.field.editedby:userinfo=`username`:ifempty=` -`+]<br />
      			`+]
      		</div>
      	`:strip+]
      	
      	[+form.guest:is=`1`:then=`
      		
      	`+]
      
                      <label for="name[+jot.id+]">Name:<br />
      		<input tabindex="[+jot.seed:math=`?+1`+]" name="name" type="text" size="40" value="[+form.field.custom.name:esc+]" id="name[+jot.id+]" />
      		</label>
      		<label for="email[+jot.id+]">Email:<br />
      		<input tabindex="[+jot.seed:math=`?+2`+]" name="email" type="text" size="40" value="[+form.field.custom.email:esc+]" id="email[+jot.id+]" />
      		</label>
                      <label for="url[+jot.id+]">Website:<br />
      		<input  tabindex="[+jot.seed:math=`?+3`+]" name="url" type="text" size="40" value="[+form.field.custom.url:esc+]" id="url[+jot.id+]" />
      		</label>
      	
      	<label for="title[+jot.id+]">Subject:<br />
      	<input tabindex="[+jot.seed:math=`?+4`+]" name="title" type="text" size="40" value="[+form.field.title:esc+]" id="title[+jot.id+]"/>
      	</label>
      	<label for="content[+jot.id+]">Comment: *<br />
      	<textarea tabindex="[+jot.seed:math=`?+5`+]" name="content" cols="50" rows="8" id="content[+jot.id+]">[+form.field.content:esc+]</textarea>
      	</label><br />
      	
        [+jot.captcha:is=`1`:then=`
      		<div style="width:150px;margin-top: 5px;margin-bottom: 5px;"><a href="[+jot.link.current:esc+]"><img src="[(base_url)]manager/includes/veriword.php?rand=[+jot.seed+]" width="148" height="60" alt="If you have trouble reading the code, click on the code itself to generate a new random code." style="border: 1px solid #003399" /></a></div>
      		<label for="vericode[+jot.id+]">Help prevent spam - enter security code above:<br /><input type="text" name="vericode" style="width:150px;" size="20" id="vericode[+jot.id+]" /></label> 
      	`:strip+]
      	
      	<div style="float:right;width: 100px;"></div>
      	<input tabindex="[+jot.seed:math=`?+6`+]" name="submit" type="submit" value="[+form.edit:is=`1`:then=`Save Comment`:else=`Post Comment`+]" />
      	[+form.edit:is=`1`:then=`
      		<input tabindex="[+jot.seed:math=`?+7`+]" name="submit" type="submit" value="Cancel" onclick="history.go(-1);return false;" />
      	`+] 
      	</fieldset>
      </form>
      

        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 27708 MODX Staff
        • 2,502 Posts
        Thanks but it is still not saving the email and name to the db. Can’t figure it out. sad

        Any other suggestions? I changed the jot call to uncached and that didn’t work. I am at a loss for the issues. Here. Grr.
          Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
          • 20413
          • 2,877 Posts
          I’ve played with jot a lot and I don’t see why this is not working either! huh

          Try add parameters of canpost, canmoderate even just blank =``
          and try set the names in order: &customfields=`name, email, url`
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 27708 MODX Staff
            • 2,502 Posts
            Okay, I think the problem seems to be that the custom fields is only taking the value for the first item in the `name, email, url` no matter what order they are in. Only the first sad .

            I have solved it! custom fields MUST be comma separated but cannot contain spaces. Spaces is breaking it and causing the data to not write. Boo. I’ll update the Wiki to so reflect that.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub