Hi Experts,
I am trying to create a new custom form that is extended from the "Controller" class. I have seen many tutorials but all the controllers are extending from CMS Controllers. I am trying to use the case when the CMS bundle/package is not included and building it from scratch. Here is my code i.e.
Controller location: mysite/code/controllers/GalleryController.php
class GalleryController extends Controller {
private static $allowed_actions = array(
'index',
'addForm' => 'ADMIN',
);
public function index(SS_HTTPRequest $request)
{
return $this->getResponse();
}
public function add(SS_HTTPRequest $request){
$fields = new FieldList(
TextField::create('imageName', 'Image Name')
);
$actions = new FieldList(
FormAction::create("galleryActMsgs")->setTitle("Gallery Images Area")
);
$form = new Form($this, 'addForm', $fields, $actions, $required);
return $form;
}
public function galleryActMsgs($data, Form $form){
$form ->sessionMessage("Data Saved Successfully....", 'success');
return $this->redirectBack();
}
Template file created at: mysite/templates/GalleryController_add.ss
$addForm
URL to access the above controller i.e.
http://localhost:8011/ss_pac/gallery/addForm
NOTE: The above URL was working fine before adding form code.
Error by accessing the above url:
There seems to have been a technical problem. Please click the back button, refresh your browser, and try again.
I tried the following steps i.e.
http://localhost:8011/ss_pac/dev/build?flush=all The above url build everything without any error.
http://localhost:8011/ss_pac/gallery/addForm?flush=1 This gives the same above error.
Looking for a quick help on it and hope this will be helpful for others as well.
Cheers,
Naveed.