submitContent macro Host Field

37 views
Skip to first unread message

LWard

unread,
May 1, 2013, 11:46:54 AM5/1/13
to dot...@googlegroups.com
Hello,

We have a submitContent macro setup for a Structure with a Host Folder field.

The field info is:
Label - Host
Display - Host or Folder
Variable - host1
Alias Name - system_field2
Required - No
Indexed - Yes
Show in List - No

We are trying to set a default value for this field, but keep the field hidden so that front end users cannot change the host that they are posting content to.

We have tried to follow the documentation show here: http://dotcms.com/docs/latest/SubmitContentForm
#set($defaultHost = $host.identifier) does not seem to do anything,
nor does
#set($defaultHost = "{identifier}")


Also, a second issue with the form is that a url resource name, a custom field is not getting set, is there a way do set that with out displaying it.

Maria Ahues Bouza

unread,
May 1, 2013, 5:17:58 PM5/1/13
to dot...@googlegroups.com
For the default use the velocityvarname.

So if the velocityvarname is hostfolder the default should be

defaultHostfolder




--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
Visit this group at http://groups.google.com/group/dotcms?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Community Manager

dotCMS
Main: 305.900.2001
Fax: 305.397.2579
www.dotcms.com
http://www.twitter.com/dotCMS
http://www.facebook.com/dotCMS
http://www.twitter.com/mabouza

Please consider the planet before printing this email.

LWard

unread,
May 8, 2013, 4:09:11 PM5/8/13
to dot...@googlegroups.com
Hello,

So if we use #set($defaultHost1 = $host.identifier) it should work, correct?

This doesn't work in 2.2.1 and it also doesn't work if you try to hard code the host identifier variable either.

Maria Ahues Bouza

unread,
May 9, 2013, 12:25:19 AM5/9/13
to dot...@googlegroups.com
If host1 is your velocityVarName this should work
 #set($defaultHost1 = $host.identifier)

Have you tried with another field? 

I tested this a couple of days ago with a couple of fields, not with Host field, and it worked.

It's possible we handle the host field in a different way.

If you add a defaultHost1 and also add the field in the don't show, then see if you get the hidden field on your form (when you view the source)


Sarah C

unread,
May 23, 2013, 8:39:21 AM5/23/13
to dot...@googlegroups.com
Solution:

Add the following below the SubmitContent() function

 <script>
   dojo.addOnLoad(function(){
       if(dojo.byId("host1FieldInput")){
        dojo.byId("host1FieldInput").innerHTML="<input type='hidden' id='host1' name ='host1' value='$!{defaultHost1}'>"
       }
   })
</script>
Reply all
Reply to author
Forward
0 new messages