Jeremy Burns
http://www.classoutfit.com
On 28 Jun 2011, at 03:47, Sanfly wrote:
In the eternal words of Homer Simpson: 'Doh'
I so should have realised that!
Does anyone have a comment/suggestion on question 2?
Cheers
On Jun 28, 9:05 am, Jeremy Burns | Class Outfit
<jeremybu...@classoutfit.com> wrote:Q1: The form is doing exactly what you want it to as the $i is inside single speech marks. Try $this->Form('Member.'.$i.'.name', ... then see what happens with validation.Jeremy BurnsClass Outfithttp://www.classoutfit.comOn 27 Jun 2011, at 20:38, Sanfly wrote:My question is in two partsIm making a form that has a certain part of it built with a 'for'loop. This form is for a booking: the first couple of fields are forthe main contact details for the booking, the looped section is to getthe details for each person included in the booking, up to a maximumof 10 people.Please note: at this point the information is not being stored in adatabase, just being emailed.Below is my form as I have it now. I have removed some fields tosimplify it for this purpose, but once the form is submitted, somevalidation is done.Question 1:Is there any way that I can use cakePHP to build the looped formfields?<?=$this->Form->text('Member.$i.name', array("size" => "40", "label"=> false));?> does not work within the for loop, the fields end upwith: name="[Member][$i][name]" rather than name="[Member][1][name]"etc...Question 2I want to do the validation and if there are issues, have the formrepopulated with the data (if all okay, will redirect to anotherpage). My non-looped fields are repopulated with the data, but notthe looped fields. What is required to get this to happen?Hope this all makes sense...<?=$this->Form->create('booking', array('url' => '/bookings/bookingform', 'onSubmit' => 'return checkRequiredFields()'));?><table width="100%"><tr><td align="right"><b>Name: </b></td><td><?=$this->Form->text('Booking.name', array("size" => "40","label" => false, "onBlur" => "copyName()"));?> <b style="color:#FF0000">*</b> </td></tr><tr><td align="right"><b>Email: </b></td><td><?=$this->Form->text('Booking.email', array("size" => "40","label" => false));?> <b style="color: #FF0000">*</b> </td></tr></table><br><table cellpadding="0"><tbody><tr><td width="190"><b>Full Name</b></td><td width="40"><b>Age<br><span style="font-size: smaller">(if under25)</span></b></td></tr><? for ($i = 1; $i <= 10; $i++){ ?><tr><td><input type="text" size="22" name="data[Member][<?=$i?>][name]"id="Member<?=$i?>Name"></td><td><input type="text" size="3" name="data[Member][<?=$i?>][age]"id="Member<?=$i?>Age"></td></tr><? } ?><tr><td colspan="5"><?=$this->Form->button('CANCEL', array('style' => 'display:inline', 'onclick' => 'history.back()')); ?> <?=$this->Form->button('FINISH BOOKING', array('id' =>'finishSubmit', 'type'=>'submit', 'style' => 'display: inline', 'name'=> 'submit', 'value' => 'finshApplication', 'onclick' => "if(confirm('Are you sure?')){return true;}return false; "));?></td></tr></table>--Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.orgCheck out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.To unsubscribe from this group, send email tocake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment