/** * This method returns a default action where to send the form if none was * excplicit setted via Form::setAction() * * @param \FormObject\Form $form * @return string **/ public function setActionUrl(Form $form) { $current = explode('/', rtrim($this->urlProvider->currentUrl(), '/')); $lastSegment = array_pop($current); if (in_array($lastSegment, ['create', 'edit'])) { $parentUrl = implode('/', $current); $form->setAction($parentUrl); } else { $form->setAction($this->urlProvider->currentUrl()); } if ($lastSegment == 'create') { $form->setVerb('post'); return; } if ($lastSegment == 'edit') { $form->setVerb('put'); return; } }
/** * This method returns a default action where to send the form if none was * excplicit setted via Form::setAction() * * @param \FormObject\Form $form * @return string **/ public function setActionUrl(Form $form) { return $form->setAction(strtok($_SERVER["REQUEST_URI"], '?')); }
/** * This method returns a default action where to send the form if none was * excplicit setted via Form::setAction() * * @param \FormObject\Form $form * @return string **/ public function setActionUrl(Form $form) { $form->setAction($this->currentUrl()); }