[TYPO3-mvc] How to use partial validation for a multi-step form

Sebastian Felix Schwarz schwarz at takomat.com
Tue May 31 13:12:04 CEST 2011


Hi Peter, 

i'm using typo3 4.5.3 with the newest extbase/fluid Extensions (1.3.0)

first of all i copied the file: ExtendedValidatorResolver 
in my extension: Classes/Validation/ExtendedValidatorResolver
then i created a basecontroller:

class Tx_Dpregistry_Controller_BaseController extends Tx_Extbase_MVC_Controller_ActionController {
protected function registerPartialValidatorForArgument($argumentName) {

        if ($this->request->hasArgument($argumentName)) {

                // Initialize the extended validator resolver.
            $extendedValidatorResolver = t3lib_div::makeInstance('Tx_Dpregistry_Validation_ExtendedValidatorResolver');
            ... AND SO ON .... 
        }
    }
}

my Extension controller extends the Basecontroller
class Tx_Dpregistry_Controller_DomainPackageController extends Tx_Dpregistry_Controller_BaseController {

	//and here i implemented the steps:

	/**
	 * Displays a form for creating a new  DomainPackage
	 *
	 * @param Tx_Dpregistry_Domain_Model_DomainPackage $newDomainPackage a fresh DomainPackage object which has not yet been added to the repository
	 * @return void
	 * @dontvalidate $newDomainPackage
	 */
	public function showstep1Action  (Tx_Dpregistry_Domain_Model_DomainPackage $newDomainPackage = NULL) {
		$this->view->assign('newDomainPackage', $newDomainPackage);
		$this->view->render();
	}

	public function initializeSavestep1Action(){
		
		$this->registerPartialValidatorForArgument('domainname');
		$this->registerPartialValidatorForArgument('endungDe');
		$this->registerPartialValidatorForArgument('endungCom');
		$this->registerPartialValidatorForArgument('spaeterReg');
		$this->registerPartialValidatorForArgument('paketname');
	
	}
	
	public function savestep1Action (Tx_Dpregistry_Domain_Model_DomainPackage $newDomainPackage){
		//$this->flashMessageContainer->add('save action1.');
		$this->redirect('showstep2Action');
	}

	/**
	 * Displays a form for creating a new  DomainPackage
	 *
	 * @param Tx_Dpregistry_Domain_Model_DomainPackage $newDomainPackage a fresh DomainPackage object which has not yet been added to the repository
	 * @return void
	 * @dontvalidate $newDomainPackage
	 */
	public function showstep2Action  (Tx_Dpregistry_Domain_Model_DomainPackage $newDomainPackage) {
		$this->view->assign('newDomainPackage', $newDomainPackage);
		$this->view->render();
	}
	
	public function savestep2Action (Tx_Dpregistry_Domain_Model_DomainPackage $newDomainPackage){
		$this->flashMessageContainer->add('save action2.');
		$this->domainPackageRepository->add($newDomainPackage);
		$this->flashMessageContainer->add('Your new DomainPackage was created.');
		
		$this->redirect('list');
	}
	
	public function initializeSavestep2Action(){
		
		$this->registerPartialValidatorForArgument('firma');
		$this->registerPartialValidatorForArgument('vorname');
		$this->registerPartialValidatorForArgument('name');
		$this->registerPartialValidatorForArgument('strasse');
		$this->registerPartialValidatorForArgument('hausnummer');
		$this->registerPartialValidatorForArgument('plz');
		$this->registerPartialValidatorForArgument('ort');
		$this->registerPartialValidatorForArgument('email');
		$this->registerPartialValidatorForArgument('telefon');
	
	}

	/**
	 * Displays all DomainPackages
	 *
	 * @return void
	 */
	public function listAction() {
		
		$domainPackages = $this->domainPackageRepository->findAll();
		$this->view->assign('domainPackages', $domainPackages);
	}

}

so, i have 2 HTML-Template.

showstep1.html
<f:section name="main">
<h1>New DomainPackage Step1</h1>

<f:flashMessages />


<f:render partial="FormErrors" arguments="{formName: 'newDomainPackage'}" />

<f:form method="post" action="savestep1"  name="newDomainPackage" object="{newDomainPackage}">
<f:render partial="DomainPackage/FormFieldsStep1" />
	<f:form.submit value="Create new" />
</f:form>
</f:section>

showstep2.html
<f:form method="post" action="savestep2"  name="newDomainPackage" object="{newDomainPackage}">
<f:render partial="DomainPackage/FormFieldsStep1" />
	<f:form.submit value="Create new" />
</f:form>
</f:section>


But i doesnt work .... 
it seems it happens ... nothing ... 

Am 31.05.2011 um 12:51 schrieb Peter Niederlag:

> Hello,
> 
> Am 30.05.2011 20:19, schrieb Sebastian Felix Schwarz:
>> Hi List,
>> 
>> i found Sebastian's Kurführst Wiki-Article about Multi-Step-Forms in the T3-Forge Rep.
>> I hope i included all things correctly, but it doesnt work ...
> 
> It was created and tested with extbase <= 1.1, I haven't tested it with a recent extbase yet, it might(!) need some adjustements?
> 
>> First of all, i call in my Template: Showstep1.html the action="savestep1" by submitting the button.
>> But i getting the error-fields of the required-form-fields from step 2 :
> 
> It is very hard to tell without knowing the exact setup, templates etc. pp..
> 
> [...]
> 
> Greets,
> Peter
> -- 
> Peter Niederlag
> http://www.niekom.de * TYPO3 & EDV Dienstleistungen *
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc

....................................................................
Sebastian Felix Schwarz
Leiter Multimedia Produktion

takomat GbR | Neptunplatz 6b | 50823 Köln

E-mail: schwarz at takomat.com
Online: http://www.takomat.com

Tel: +49 (0)221 - 75905-03
Fax: +49 (0)221 - 75904-02
....................................................................

takomat GbR, Inh.: Johne, Schwarz, Buller u. Jakubowski
Sparkasse Köln-Bonn: BLZ 370 501 98 – Kto. 190 144 7076, 
Steuernummer: DE 258/513/199, Erfüllungsort und Gerichtsstand ist Köln. Sitz der Gesellschaft ist Köln.

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.



More information about the TYPO3-project-typo3v4mvc mailing list