What is the correct way to View my Controller's Form and other Actions without creation the new Page Type? Now i created a new Page Type and show in it's layout the form to add some information. On this form I need to add captcha only for guests users in front-end and show the same form (and other actions returned values) for custom user groups in back-end but without captcha.
Class for Database model (mysite/code/mineDataObject.php):
<?php
class mineDataObject extends DataObject{
private static $db = array(
'Name' => 'Varchar(256)',
'Street' => 'Varchar(56)',
'Telephone' => 'Varchar(11)'
);
}
?>
Controller class (mysite/code/mineController.php):
<?php
class mine extends Page{}
class mine_Controller extends Page_Controller{
private static $allowed_actions = array('mineForm');
public function mineForm(){
$fields = new FieldList(
new TextField('Name', 'Name'),
new TextField('Street', 'Street'),
new PhoneNumberField('Telephone', 'Telephone')
);
$actions = new FieldList(
new FormAction('doAdd','Submit')
);
$validator = new RequiredFields('Name', 'Street', 'Telephone');
return new Form($this, 'mineForm', $fields, $actions, $validator);
}
public function doAdd($data, $form) {
$submission = new mineDataObject();
$form->saveInto($submission);
$submission->write();
return $this->redirectBack();
}
}
?>
If it's already right way - then how to make that users will can create only one instance of this Page Type?
I tried to config Director for my controllers form action, but it's not work for me.
routes.yml
---
Name: mineroutes
After: framework/routes#coreroutes
---
Director:
rules:
'mine//$Action' : 'mine_Controller'
If it's right way then I just need to add links for controller and it's actions in Page. ss template, but how to configure permissions to it, for example hide some action from site guest and show it only to group named "Site Redactor"?
If go to http://myweb.site/mine/mineForm - it will return error.
Thanks a lot for any help!