Re: incorrect resulting array from a multiselect option problem please help
ok..ill try that one..but im out of town...ill try it out soon as i arrive.. thanx a lot; ) On Sep 16, 2:05 am, WebbedIT wrote: > Try this > > input($j.'.OfferedSubject.Course',array > ('multiple'=>true)); ?> > > If the form helper is building the select right, the above will change > it from a single select to multiple select. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: incorrect resulting array from a multiselect option problem please help
Try this input($j.'.OfferedSubject.Course', array ('multiple'=>true)); ?> If the form helper is building the select right, the above will change it from a single select to multiple select. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: incorrect resulting array from a multiselect option problem please help
sir Webbedit heres my rel: Subject hasMany OfferedSubject OfferedSubject HABTM Course heres my controller without the save: function offeredSubjectAdd($subjectId = null, $lastSec = null, $numSec = null){ debug($this->data); if(isset($this->data['numSec'])){ $this->Session->write('OfferedSubject.numSec',$this->data ['numSec']); } $courses = $this->College->listCourses(); $subjects = $this->Subject->find('first',array( 'conditions' => array( 'Subject.id =' => $subjectId ) ) ); $colleges = $this->Campus->listColleges(); $this->set('numSec',$this->Session->read('OfferedSubject.numSec')); $this->set(compact('courses', 'subjects', 'colleges','subjectId', 'lastSec')); $this->layout = 'ajax'; } heres my view: codeBlock('window.location = "'.$url.'"'); ?> flash(); ?> form(array( 'type' => 'post', 'options'=>array( 'url'=>array( 'controller'=>$this->params['controller'], 'action'=>'offeredSubjectAdd'.'/'.$subjectId.'/'.$lastSec.'/'. $numSec ), 'model'=>'OfferedSubject', 'update'=>'results' ) )); ?> > input($j.'.section'); ?> input($j.'.days'); ?> input($j.'.times'); ?> input($j.'.room'); ?> input($j.'.limits'); ?> input($j.'.gender_flag',array( 'type'=>'select', 'options'=> array( 'M'=>'M', 'F'=>'F' ), 'empty'=>'Choose One' ) ); ?> input($j.'.college_id');?> input($j.'.OfferedSubject.Course'); ?> end('Submit');?> i followed what you suggest but just in the input($j.'.OfferedSubject.Course'); ?> part but instead of having a multiselect it changes to a normal select option the cookbook said that: "A more likely scenario with a HABTM relationship would include a set to allow multiple selections. For example, a Recipe can have multiple Tags assigned to it. In this case, the data is pulled out of the model the same way, but the form input is declared slightly different. The tag name is defined using the ModelName convention." thats why i only used input('Course'); ?> before and now im still stuck with the resulting array... its been days now,still no luck; ( @brian, i did not receive your message.sorry @webbedit, thanx for your help, i want to hear more from you sir.. than
Re: incorrect resulting array from a multiselect option problem please help
It seems to be a new thread. On Tue, Sep 15, 2009 at 5:08 AM, WebbedIT wrote: > > @ learning_cake_php: I just took ages to submit a reply which seems to > have gone nowhere, did I send it to you via email? (i.e. clicked > 'reply to author') > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: incorrect resulting array from a multiselect option problem please help
@ learning_cake_php: I just took ages to submit a reply which seems to have gone nowhere, did I send it to you via email? (i.e. clicked 'reply to author') --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: incorrect resulting array from a multiselect option problem please help
As my post states, I do not believe you can save multiple OfferedSubject at once, each having their own HABTM Course. You would need to create a form which produces an array as shown above. Now I am have no idea about your schema as your form obviously includes data from Subject and Section models which you have not mentioned, it would be be helpful to know more about your schema, it's associations, the controller action which passes the data to this view and possibly a link to see the form online. However, I will attempt to give you an idea of what you're trying to achieve (this assumes your passing a $OfferedSubjects array from the controller which contains a row for each OfferedSubject). $value): ?> > input($key.'.OfferedSubject.section'); ?> input($key.'.OfferedSubject.days'); ?> input($key.'.OfferedSubject.times'); ?> input($key.'.OfferedSubject.room'); ?> input($key.'.OfferedSubject.limits'); ?> input($key.'.OfferedSubject.gender_flag',array ( 'type'=>'select', 'options'=>array('M'=>'M','F'=>'F'), 'empty'=>'Choose One' ));?> input($key.'.OfferedSubject.college_id');?> input($key.'.OfferedSubject.Course'); ?> I'm not sure how the automagic will behave when prefixing field names with the numerical array key, but the above would output the right data array that could then be looped through in the controller calling saveAll() for each OfferedSubject saving it's HABTM Course at the same time. Doing this alone is fairly advanced for a CakePHP newbie, then taking into account the fact your submitting this via Ajax ups the complication further, good luck! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: incorrect resulting array from a multiselect option problem please help
oh thank God someone did read my post and answer it. thanx webbedIT! but how could i have the array you presented if i want to maintain the same view as i did on my post? or can you share me any idea on how to go about saving multiple OfferedSubject at once, each having their own HABTM Course. please help.. learning_cakephp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: incorrect resulting array from a multiselect option problem please help
Wow, that was a long post ... not many people will stck around to read all of that :o) >From what I have read it appears you are trying to save multiple OfferedSubject at once, each having their own HABTM Course. For starters, you simply can't use one save call to do this. You can use saveAll() to save one OfferedSubject along with it's HABTM data, but not many OfferedSubject and their individual HABTM data. If you want to stick with the same view then you would have to loop through the build the data array so you could then loop through it in the controller saving each OfferedSubject along with it's HABTM Course data. the data array would have to be Array ( [0] => Array ( [OfferedSubject] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 [college_id] => 1 ) [Course] => Array ( [Course] => Array ( [3] => 1 [7] => 1 [12] => 1 ) ) ) [1] => Array ( [OfferedSubject] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 [college_id] => 1 ) [Course] => Array ( [Course] => Array ( [5] => 1 ) ) ) [2] => Array ( [OfferedSubject] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 [college_id] => 1 ) [Course] => Array ( [Course] => Array ( [2] => 1 [9] => 1 ) ) ) ) The way you have it, each time you echo your Course input field it is overwriting the previous Course input as they've all got the same id and name. Hope this helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---