Re: Dynamic form fields / multi-dimension array inside $this->data
Thanks guys. I've also discovered that I can flatten those arrays out and do some array jiggling to accommodate my need. On Oct 18, 5:08 am, francky06l <[EMAIL PROTECTED]> wrote: > I found a "syntax" in order to do this with form helper in cake 1.2 > > $form->input('Request/group][1][test' > will give data['Request']['group'][1]['test'] > > $form->input('Request/group][1][3][test' > will give data['Request']['group'][1][3]['test'] > > $form->input('Request/group][1][3][5][test' > will give data['Request']['group'][1][3][5]['test'] > > hope this helps > > On Oct 17, 6:47 pm, daphonz <[EMAIL PROTECTED]> wrote: > > > Sure. > > > The following example uses Cake 1.2's FormHelper, but the general > > syntax should work for 1.1's HTMLHelper: > > for ($i=0;$i<$weekMax;$i++) { > > echo $form->text('User.start]['.$i); > > > } > > > Or you could just generate the inputs by hand, using the structure: > > > value="" /> > > > value="" /> > > etc. > > > Using either of the above methods, the $this->data array in your > > controller will have $this->data['start'] as an array with the same > > number of elements you specified in your view. You could then > > serialize this array before storing it in your DB to reduce the number > > of fields you need. > > > Hope this helps, > > > Casey > > > On Oct 16, 12:20 pm, MarsDev <[EMAIL PROTECTED]> wrote: > > > > Hi guys, > > > > I am building a training scheduling app where I am stuck at the weekly > > > schedule list form. Each training class is a multi-week schedule, > > > somewhere between 15-20 weeks. I have a table that keep tracks thes > > > length of the training class. However, when it comes to the frontend > > > rendering, I don't know how to assign the text fields to capture all > > > the start date / end date of the each week: > > > > For example: > > > > > > Week 1 > > > > > > input('User/start_date', array('size' => > > > '20')?> > > > tagErrorMsg('User/start_date', 'Start > > > Date > > > is required'); ?> > > > > > > > > > > > input('User/end_date', > > > array('size' => '20')?> > > > > > $html->tagErrorMsg('User/end_date', 'End Date is required'); ?> > > > > > > > > > > ... > > > ... > > > > Is there some way to make cakePHP keep all week schedule data into > > > $this->data['User']['start'][0] to $this->data['User']['start'][15], > > > for instance? If so, what should I put for the first parameter of > > > HtmlHelper::input() method? > > > > Thanks a lot!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Dynamic form fields / multi-dimension array inside $this->data
I found a "syntax" in order to do this with form helper in cake 1.2 $form->input('Request/group][1][test' will give data['Request']['group'][1]['test'] $form->input('Request/group][1][3][test' will give data['Request']['group'][1][3]['test'] $form->input('Request/group][1][3][5][test' will give data['Request']['group'][1][3][5]['test'] hope this helps On Oct 17, 6:47 pm, daphonz <[EMAIL PROTECTED]> wrote: > Sure. > > The following example uses Cake 1.2's FormHelper, but the general > syntax should work for 1.1's HTMLHelper: > for ($i=0;$i<$weekMax;$i++) { > echo $form->text('User.start]['.$i); > > } > > Or you could just generate the inputs by hand, using the structure: > value="" /> > value="" /> > etc. > > Using either of the above methods, the $this->data array in your > controller will have $this->data['start'] as an array with the same > number of elements you specified in your view. You could then > serialize this array before storing it in your DB to reduce the number > of fields you need. > > Hope this helps, > > Casey > > On Oct 16, 12:20 pm, MarsDev <[EMAIL PROTECTED]> wrote: > > > Hi guys, > > > I am building a training scheduling app where I am stuck at the weekly > > schedule list form. Each training class is a multi-week schedule, > > somewhere between 15-20 weeks. I have a table that keep tracks thes > > length of the training class. However, when it comes to the frontend > > rendering, I don't know how to assign the text fields to capture all > > the start date / end date of the each week: > > > For example: > > > > Week 1 > > > > input('User/start_date', array('size' => > > '20')?> > > tagErrorMsg('User/start_date', 'Start Date > > is required'); ?> > > > > > > > > input('User/end_date', > > array('size' => '20')?> > > > $html->tagErrorMsg('User/end_date', 'End Date is required'); ?> > > > > > > > ... > > ... > > > Is there some way to make cakePHP keep all week schedule data into > > $this->data['User']['start'][0] to $this->data['User']['start'][15], > > for instance? If so, what should I put for the first parameter of > > HtmlHelper::input() method? > > > Thanks a lot!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Dynamic form fields / multi-dimension array inside $this->data
Sure. The following example uses Cake 1.2's FormHelper, but the general syntax should work for 1.1's HTMLHelper: for ($i=0;$i<$weekMax;$i++) { echo $form->text('User.start]['.$i); } Or you could just generate the inputs by hand, using the structure: etc. Using either of the above methods, the $this->data array in your controller will have $this->data['start'] as an array with the same number of elements you specified in your view. You could then serialize this array before storing it in your DB to reduce the number of fields you need. Hope this helps, Casey On Oct 16, 12:20 pm, MarsDev <[EMAIL PROTECTED]> wrote: > Hi guys, > > I am building a training scheduling app where I am stuck at the weekly > schedule list form. Each training class is a multi-week schedule, > somewhere between 15-20 weeks. I have a table that keep tracks thes > length of the training class. However, when it comes to the frontend > rendering, I don't know how to assign the text fields to capture all > the start date / end date of the each week: > > For example: > > Week 1 > > input('User/start_date', array('size' => > '20')?> > tagErrorMsg('User/start_date', 'Start Date > is required'); ?> > > > > > input('User/end_date', array('size' > => '20')?> > $html->tagErrorMsg('User/end_date', 'End Date is required'); ?> > > > > ... > ... > > Is there some way to make cakePHP keep all week schedule data into > $this->data['User']['start'][0] to $this->data['User']['start'][15], > for instance? If so, what should I put for the first parameter of > HtmlHelper::input() method? > > Thanks a lot!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Dynamic form fields / multi-dimension array inside $this->data
Hi guys, I am building a training scheduling app where I am stuck at the weekly schedule list form. Each training class is a multi-week schedule, somewhere between 15-20 weeks. I have a table that keep tracks thes length of the training class. However, when it comes to the frontend rendering, I don't know how to assign the text fields to capture all the start date / end date of the each week: For example: Week 1 input('User/start_date', array('size' => '20')?> tagErrorMsg('User/start_date', 'Start Date is required'); ?> input('User/end_date', array('size' => '20')?> tagErrorMsg('User/end_date', 'End Date is required'); ?> ... ... Is there some way to make cakePHP keep all week schedule data into $this->data['User']['start'][0] to $this->data['User']['start'][15], for instance? If so, what should I put for the first parameter of HtmlHelper::input() method? Thanks a lot!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---