Adding Text Box in Composer Form

Permalink
I am setting up page type for events that will have different info. like location, date, time, etc...

I have the page type and template set up. I am able to add each of the new fields for the composer form, but I notice that there isn't a text box or radio button, common form fields, etc.. For example, for a location I would really like to use a text box instead of having to use a big content block. How can I do that?

Also, any way to get a date picker to work in there? I have tried creating a datepicker block in Block Designer, but it doesn't pull over the functionality.

keydin
 
ob7dev replied on at Permalink Reply
ob7dev
Heya keydin,

There's two (easy) ways to add a text box to your composer form:

Option One :: Custom Attribute in Composer Form
When you are adding attributes to a composer form, there is built in attributes, and there is custom attributes. You will need to add a textarea attribute that you can then add to your composer form by going to:
Pages & Themes -> Attributes

At the bottom of this page you will see an area for adding new attributes. Simply use the select input and choose 'Text Area' and click 'Go'.

The handle is usually all lower case, used by developers coding things that need to grab data from attributes of this type on a page. The Name usually is called the same but you can properly capitalize it and call it something like "Text Area".

You can choose a set to add it to but its not necessary.

The last option is whether its a plain text input, which is a normal text area input such as a message area on a contact form, or you can select 'Rich Text - Default Setting', which will give you a text area similar to a content block, where you can change text styles and such. Don't let the 'Default Setting' confuse you, as you may assume that means its the default setting for your new attribute but thats not the case. It means you want a rich text field with default settings instead of a plain text field with no styling options.

When your ready, click 'Add' on the bottom right.


Now that our rich text field is created, lets go back to 'Edit Form' on the page type you want to add to your composer form.

Click the plus icon to add a new attribute, click the tab on the right that says "Custom Attribute". From here you will find your newly created text area attribute. Find it, click it and it will be added to your composer form.

Now your probably wondering how to display that data on the page? Well the easiest way is to add a new 'Page Attribute' block to the page (listed under Multimedia in the block sidebar) and then select your Text Area attribute. Now your data from the composer form is displayed in this block.


Option 2 :: Content Block in Composer Form
If you don't want to manually add the Page Attribute block everytime you do this, but have your custom page type automatically show whatever is input in the composer form on the page when its published, we will need to do the same thing the default 'Page' type does and add a content block to our composer form instead of a custom attribute, then we need to add the blocks view to our template output, like so:

1. Click Page Types -> Edit Form on your custom page type.
2. Add a Form Control, this time choose 'Content' under blocks instead of a custom attribute.
3. Click back to list, now click 'Output' on your custom page type. Click the page template you want to add the Content block output to (such as Full). Click Edit Defaults.
4. Now you can edit the template used every time a new page is made using your custom page type. To add the composer content block output to the page, click + in the top left to add a block. Scroll to the very bottom and you will see a block type called 'Composer Control'. Drag this block to where you want its output to be displayed. It will ask you to select which composer block you want to output. If you've only added one block to your composer form, there will only be one option. The option will be named whatever its called in your form. If you added a Content Block, by default it will be called 'Content'. If you add multiple blocks of the same type by default they all have the same name. To help distinguish between them you should change the name of the block in the composer form back over on the 'Edit Form' page for your custom page type, and clicking the pencil icon on the item and giving it a custom title.

Now whenever you make a new page of this type, the content put into the composer form will automatically be output to wherever you dragged the Composer Control block.

Hope that helps! Let us know if you need anything else.