[FLOW3-general] Edit Form with two seperate target actions

Nick nick at jamalade.com
Wed Oct 3 14:57:07 CEST 2012


Hi Jan,

Looks like quite a nice solution, except for using the value (displayed string) of the button.

I was trying a similar thing, am using extbase and fluid, and I came up with something similar to your earlier "Ugly" version.
Except in mine I had used different names for the Submit buttons, this way you could use f:translate to set the value and displayed name of the string.

so in mine (but using your example):

/*** FORM (Resources\Private\Templates\Location\Edit.html)*************/
<f:form action="update" object="{location}" name="location">
         <ol>
                 [ ... Other Fields ... ]
                 <li>
                         <f:form.submit class="btn btn-big" 
value="Speichern und zurück" name="saveAndBack" />
                         <f:form.submit value="Speichern" 
name="save" class="btn btn-big"/>
                 </li>
         </ol>
</f:form>
/**********************************************************************/


/**** Action in Controller (Classes\Controller\LocationController.php)*/
/**
  * Updates the given location object
  *
  * @param \JPG\Trainings\Domain\Model\Location $location The location to update
  * @return void
  */
public function updateAction(\JPG\Trainings\Domain\Model\Location $location) {

         if(($location->getLan() == '')||($location->getLat() == '')) {
                 $this->findCoordinates($location);
         }

         if($this->request->hasArgument('saveAndBack')){
                 $this->locationRepository->update($location);
                 $this->addFlashMessage('Updated the location.');
                 $this->redirect('edit', 'Location', NULL, 
array('location' => $location));
         } elseif($this->request->hasArgument('save')){
                 $this->locationRepository->update($location);
                 $this->addFlashMessage('Updated the location.');
                 $this->redirect('index');
         }
}

Ugly but it doesn't rely on displayed values for which you can use f:translate etc. Also you can assign values to view for the button names.

Would be nice if the non "Ugly" way wasn't dependant on the displayed value of the button, any ideas?

thanks

Nikos




More information about the FLOW3-general mailing list