Hard coded form
Permalink 1 user found helpful
I've got problems with hard coded forms.
I've previous added a form as a block. Now I want to use that form on a different amount of pages (using Default Page Types is not a solution for me).
After adding the hard coded to the page type I do see the form, but the FORM ACTION url is not correct.
Instead of getting the URL i only get .
Help is very welcome.
I've previous added a form as a block. Now I want to use that form on a different amount of pages (using Default Page Types is not a solution for me).
$bt = BlockType::getByHandle('form'); $bt->controller->bID = '2164'; $bt->controller->questionSetId = '1282723354'; $bt->controller->surveyName = 'Form name'; $bt->controller->thankyouMsg = 'Thanks'; $bt->controller->notifyMeOnSubmission = '1'; $bt->controller->recipientEmail = 'user@domain.name'; $bt->controller->displayCaptcha = '0'; $bt->controller->redirectCID = '0'; $bt->render('templates/form');
After adding the hard coded to the page type I do see the form, but the FORM ACTION url is not correct.
Instead of getting the URL
action="/index.php?cID=298&bID=1945&arHandle=Main&ccm_token=1282738981:e00a7420ee1612eee47c648a9691c70d&btask=passthru&method=submit_form#1274798081"
action="#1282723354"
Help is very welcome.
Or no one knows what I'm talking about, or no one cares ;-)...
Unfortunately there is an issue with hard-coding blocks that rely on action() urls. They won't work. This is because there's no instance of the block ID for it to post back to. I'd like to fix this eventually but I have no idea when it's going to be.
In the meantime, I'd add the form block to a global scrapbook, name it something like "My_Form", and then display it inline like:
I _think_ that should work.
In the meantime, I'd add the form block to a global scrapbook, name it something like "My_Form", and then display it inline like:
<?php $b = Block::getByName('My_Form'); $b->display();
I _think_ that should work.
Thanks. I'm giving that a shot.
Too bad C5 has got those issues...
Too bad C5 has got those issues...
I've found the way of using the scrapbook as andrew described to be a very easy and flexible way of hardcoding blocks into templates. It makes maintenance much easier, if you need to update the email address a form goes to for example, you can do it the way it was intended through c5's interface rather than having to dig into your templates. Makes it easier for clients to make updates like that as well.