mirror of
https://github.com/a2nt/silverstripe-elemental-basics.git
synced 2024-10-22 17:05:54 +02:00
FIX: ElementForm action links
This commit is contained in:
parent
af29804172
commit
370b2c0764
@ -2,18 +2,46 @@
|
|||||||
|
|
||||||
namespace A2nt\ElementalBasics\Controllers;
|
namespace A2nt\ElementalBasics\Controllers;
|
||||||
|
|
||||||
use DNADesign\Elemental\Models\BaseElement;
|
|
||||||
use DNADesign\ElementalUserForms\Control\ElementFormController as ControlElementFormController;
|
use DNADesign\ElementalUserForms\Control\ElementFormController as ControlElementFormController;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
|
||||||
use SilverStripe\ORM\ValidationResult;
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
|
||||||
class ElementFormController extends ControlElementFormController
|
class ElementFormController extends ControlElementFormController
|
||||||
{
|
{
|
||||||
private static $allowed_actions = [
|
private static $allowed_actions = [
|
||||||
|
'Form',
|
||||||
'finished',
|
'finished',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function Form()
|
||||||
|
{
|
||||||
|
$form = parent::Form();
|
||||||
|
|
||||||
|
// Elements actions
|
||||||
|
$current = Controller::curr();
|
||||||
|
$link = $current->Link();
|
||||||
|
|
||||||
|
if (is_a($current, self::class)) {
|
||||||
|
$link = $current->getElement()->getPage()->Link();
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = Director::makeRelative($link);
|
||||||
|
$link = !$link || $link === '/' ? '/home' : $link;
|
||||||
|
|
||||||
|
$form->setFormAction(
|
||||||
|
Controller::join_links(
|
||||||
|
'/',
|
||||||
|
$link,
|
||||||
|
'element',
|
||||||
|
$this->owner->ID,
|
||||||
|
__FUNCTION__
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
public function finished()
|
public function finished()
|
||||||
{
|
{
|
||||||
$user = $this->getUserFormController();
|
$user = $this->getUserFormController();
|
||||||
|
Loading…
Reference in New Issue
Block a user