[TYPO3-mvc] validating two model in a form

Desh Naik desh.naik at lelesys.com
Sat Nov 6 06:19:58 CET 2010


On Thursday 04 November 2010 04:40 PM, Franz Koch wrote:
> Hey,
>
>> Can anyone help me in validating two models in single form eg
>>
>> suppose i have two table
>> 1 ) student (id,name,age)
>> 2) Address (student_id,city,state,pincode)
>>
>>
>> and i have a form like this
>>
>> <f:form method="post" controller="Student" action="create"
>> name="student" object="{student}" >
>> <f:form.textbox property="name" />
>> <f:form.textbox property="age" />
>> <f:form.textbox property="city" />
>> <f:form.textbox property="state" />
>> <f:form.textbox property="pincode" />
>> <f:form.submit class="submit" value="Create Master Template"/>
>> </f:form>
>>
>> from this form i want to validate (name and city ) which are in two
>> different model
>>
>> is it possible to validate 2 fields in different model or am i doing it
>> in wrong way ?
>
> well, your student doesn't have a property "city" or "state", so you 
> can't use your template as is currently. Your student most likely has 
> a property "address" which itself has the properties "city" and 
> "state". So you have to reflect that in your template in order to get 
> the values mapped to the according address model:
>
> <f:form.textbox property="address.city" />
>
> Once you changed the template accordingly, extbase should at least 
> create a student object with according address object and validate the 
> student model (if the properties of the student model have correct 
> annotations). The auto-validation of child objects is still a issue of 
> extbase. IIRC this did not work a few months ago and a ticket has been 
> created for that - not sure if current SVN version already has that 
> feature. Please have a look at the bugtracker on forge.
>
hi

Thanks for the help .
I have done that and it worked . But it is validating only for the first 
time when i clicked submit . for the second clicked it doesn't validate 
the child field and also it doesnt append the css to show the error .

Thanks


More information about the TYPO3-project-typo3v4mvc mailing list