function Link($action = null)
 {
     $form = $this->parent->getForm();
     if ($form) {
         $token = $form->getSecurityToken();
         $parentUrlParts = parse_url($this->parent->Link());
         $queryPart = isset($parentUrlParts['query']) ? '?' . $parentUrlParts['query'] : null;
         // Ensure that URL actions not routed through Form->httpSubmission() are protected against CSRF attacks.
         if ($form->securityTokenEnabled()) {
             $queryPart = $token->addtoUrl($queryPart);
         }
         return Controller::join_links($parentUrlParts['path'], 'item', $this->item->ID, $action, $queryPart);
     } else {
         // allow for instanciation of this FormField outside of a controller/form
         // context (e.g. for unit tests)
         return false;
     }
 }
Exemple #2
0
 function Link($action = null)
 {
     if ($this->parent->getForm()) {
         $parentUrlParts = parse_url($this->parent->Link());
         $queryPart = isset($parentUrlParts['query']) ? '?' . $parentUrlParts['query'] : null;
         return Controller::join_links($parentUrlParts['path'], 'item', $this->item->ID, $action, $queryPart);
     } else {
         // allow for instanciation of this FormField outside of a controller/form
         // context (e.g. for unit tests)
         return false;
     }
 }