Elemental with forms

Silverstripe Version: 4.10


I’m looking for some pointers to get started with a form built using elemental (custom block).

My end goal is to make a form that submits using ajax, but I’d just be happy to have a working form for now.

I have the form setup in my block controller and the controller is defined in the block itself. This works fine. But when using the form function, nothing is returned and the function itself isn’t triggered.

Here’s my code:

Element Block

class CTABlock extends BaseElement
	private static $singular_name 	= 'Call to action';
	private static $description 		= 'Call to action bar with customised pop up form or link';
	private static $icon 				= 'font-icon-block-bell';
	private static $controller_class 	= CTABlockController::class; /** Class is defined here */
	private static $inline_editable 	= false;


protected function init()

    public function ContactForm(HTTPRequest $request)
        /** I've stripped a lot of it out, but you get the idea, hopefully! */

        $form = Form::create(
                TextField::create('Name', 'Your Name')
                FormAction::create('sendForm', 'Send')

        return $form;


	<div class="modal fade" id="modalForm{$ID}" tabindex="-1" aria-labelledby="modalForm{$ID}Label" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title" id="modalForm{$ID}Label">{$ButtonText}</h5>
					<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
				<div class="modal-body">

So, my question is - firstly, any ideas why no form is actually returned?

Secondly, will this set up just work as expected given it’s elemental, or would it need something a bit different?

Thanks in advance for any help!