Hi,
I want to create a space blueprint where I derive the space name and space key form additional information entered in the create wizard.
In all documentation about space blueprints and in the examples I see that Confluence.Templates.Blueprints.CreateSpace.createSpaceFormFields is called from the soy template., This function is using 4 parameters, including $name and $key for the space name and the space key.
I don't understand how this function "magically" introduces the two input fields "Space name" and "Space key" on the blueprint create wizard and I also don't understand where and how the two parameters are bound to their values.
Can someone explain how I can use the createSpaceFormFields function to create my new space and bind name and key to values of other input controls of the wizard? In fact, I want to have the "Space name" and "Space key" to disappear form my wizard completely.
Thanks for your help!
Community moderators have prevented the ability to post new answers.
Hi Alice,
This was the answer I was looking for since a long time!!
Thanks a lot!
It not only solves my problem but it also (finally) gives insight in the magic (or actually that there is no magic going on at all) of the createSpaceFormFields method. I think it might be very informative to include this information in the official documentation.
Did I thank you already?
Thanks.
Merijn
Hi Merijin,
You can change the text "Space name" and "Space key" using javascript by binding to the post-render event, i.e. do a dom select and replace.
Alternatively, you can ignore createSpaceFormFields and complete the form yourself.
Here is basically what the .createSpaceFormFields is:
<fieldset> <div class="field-group"> <label for="name">{getText('create.content.plugin.space.create.form.name.label')} {if not $disableRequiredIcon} <span class="aui-icon icon-required"/> {/if} </label> <input class="text long-field" name="name" autocomplete="off" {if $name}value="{$name}"{/if}/> {if $fieldErrors and $fieldErrors['name']} {foreach $error in $fieldErrors['name']} <div class="error">{$error}</div> {/foreach} {else} <div class="error hidden"></div> {/if} </div> <div class="field-group"> <label for="spaceKey">{getText('create.content.plugin.space.create.form.key.label')} {if not $disableRequiredIcon} <span class="aui-icon icon-required"/> {/if} </label> <input class="text long-field" name="spaceKey" {if $spaceKey}value="{$spaceKey}"{/if}/> <span class="aui-icon aui-icon-small aui-iconfont-help" data-unicode="UTF+E003" data-tooltip="{getText('create.content.plugin.space.create.form.key.tooltip')}" original-title=""/> {if $fieldErrors and $fieldErrors['spaceKey']} {foreach $error in $fieldErrors['spaceKey']} <div class="error">{$error}</div> {/foreach} {else} <div class="error hidden"></div> {/if} </div> </fieldset>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Alice,
Thanks for your support.
Unfortunately, your answer is not exactly what I'm looking for. Binding the parameters is not an issue for me. I figured out how to to that.
What I do want to achieve is that the form doesn't show the text "Space name" and "Space key", but some other labels that better reflect the purpose of the new space that I'm creating. To be more precise, I want that "Space name" is replaced by "User name" and "Space key" by "User short name".
The suggestion by Minh works to some extend, meaning that I get the proper labels, but these labels are now used globally, which is of course not what I want.
Therefore, I'm still stuck and in need of a better understanding of what is happening in createSpaceFormFields. For instance, can I ignore createSpaceFormFields (or replace it with another method invocation) and create the complete form myself using the proper input field declarations?
I'm looking forward for further support, because I'm stuck.
Thanks again and thanks in advance for your further help.
Kind regards,
Merijn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Merijin,
The createSpaceFormFields function renders some basic form fields for the common space details in the Create Space dialog, like the input where users can enter the space name and space key. The optional params $name and $key passed in fill in the corresponding default value when this dialog is shown to users.
The values for these parameters can be injected into the soyRenderContext, by binding onto the pre-render event, see step 4 of https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-blueprints/space-blueprints/write-a-simple-confluence-space-blueprint.
You can manipulate the space name and key inputs to equal your custom fields by injecting custom js into one of the three wizard events during the various stages of the dialog phase depending on your need. After that, you can get rid of space name and key fields completely from the ui by hiding them from the user via js or css.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it is possible, you could overwrite the label by putting these keys inside your properties file:
create.content.plugin.space.create.form.name.label=X
create.content.plugin.space.create.form.key.label=Y
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, that works, although it feels a bit like a hack. CAn you perhaps comment on the other issues I mentioned in my question?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, it doesn't quite work, because it now uses X and Y globally on the create wizard of all types of spaces!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Minh, Thanks for your help. I was aware of the guide for creating a space blueprint. I do not understand however when/how the call is made to Confluence.Templates.Blueprints.CreateSpace.createSpaceFormFields and how parameter binding works. Is the method called when the form is submitted? If so, is it possible to bind its parameters to my own input fields? Or is the method called before and is its purpose solely to get the the two input fields (name and spaceKey) added to a form? Is it possible to have a space created from my form without making the call to Confluence.Templates.Blueprints.CreateSpace.createSpaceFormFields? The minimal thing I need to be able to do is to display other names for the input fields on the form. Is this possible and have the label "Space name" changed in e.g. "X" and the label "Space key" in e.g. "Y"? Thanks again for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Merijn de Jonge,
The guide for creating a space blueprint is here https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-blueprints/space-blueprints/write-a-simple-confluence-space-blueprint
the Confluence.Templates.Blueprints.CreateSpace.createSpaceFormFields is to generate the space key and space name fields in the dialog like previous example:
This function will generate and bind 2 input fields "Space name" and "Space key" with the field "name" and "spaceKey"
I am not quite clear about your point to create a space but you do not have 2 fields "Space name" and "Space key" in the form
Do you want to customize those 2 fields?
Thanks,
Minh Tran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.