Also, have you tried to generate code with bake? it could be helpful or you
could see what are you doing wrong at least


http://book.cakephp.org/view/1522/Code-Generation-with-Bake
Pablo E. Terradillos



On Sun, Nov 14, 2010 at 12:43 AM, Pablo Terradillos <teh...@gmail.com>wrote:

> I'm not sure if i understand correctly your first issue...
> Have your associated model the corresponding foreign key and, also, a
> primary key?
> For example,
>
> Questions
> id
> text
>
> Answers
> id
> question_id
> text
>
>
>
> Regarding the second issue,
>
> remember to enclose modelName.$i.field with double quotes so $i is treated
> as a variable or you could use 'modelName.'.$i.'field'
>
> Pablo E. Terradillos
>
>
>
>
> On Sat, Nov 13, 2010 at 11:39 PM, Rameez <rameezmust...@gmail.com> wrote:
>
>> Thank you for your response, I in fact did do what you said about the
>> first problem and resolved that error. I was passing the parameter to
>> a page that has a form. The create function in the view, would recall
>> the same action using the $options as 'action'. I added the 'url tag
>> to the' $options array. Without the tag my parameters kept
>> disappearing
>>
>> 1) However now I have come across a new problem. The parameter I pass
>> is to set the foreign key field of the Question (Survey ID). But when
>> I save $this->data, it takes the id to be the same argument
>> automatically. So it goes into the database and over writes the entry
>> with that ID instead of making a new entry.
>>  Here is my view code:
>>
>> echo $form->create('ModelName', array('url' => array('action' =>
>> 'create',$this->passedArgs[0])));
>> echo $form->input('text',array('label'=> 'Enter the Question Text'));
>> echo '<div><input type="submit" value="Next" />
>> echo $form->end();
>>
>> Inside the controller i just try to debug the id
>> Code:
>> if (!empty($this->data)) {
>>     debug($this->ModelName->id);
>>     $this->ModelName->save($this->data, array('validate' => true));
>>     redirect(somewhere);
>> }
>>
>>
>>
>> 2) As for the second question, saveAll() tries to save all the answers
>> options with the same primary id which is zero for this case. If I use
>> a loop I change the syntax like this ModelName.0.FieldName becomes
>> ModelName.$i.Fieldname where $i is the loop variable. This doesnt save
>> anything.
>>
>>
>>
>>
>>
>> On Nov 14, 3:45 am, Pablo Terradillos <teh...@gmail.com> wrote:
>> > Have your model the corresponding associations?
>> > Questions have many answers?
>> >
>> > if so, you could check what your form is POSTing using
>> debug($this->data);
>> > in order to check if you are making all in a the correct way
>> >
>> > You may not have any problems putting the form generator in a loop, as
>> long
>> > as your associations are correct (is saveAll working whenever you try to
>> > save the answers without the loop?)
>> >
>> > Pablo E. Terradillos
>> >
>> > On Fri, Nov 12, 2010 at 10:53 PM, Rameez <rameezmust...@gmail.com>
>> wrote:
>> > > I am new to cake php so please bear with me. I am trying to create a
>> > > survey for which i can create multiple choice questions. i am running
>> > > into two issues
>> >
>> > > 1) for multiple choice questions i have a form that takes all the
>> > > answer choices and saves them as separate entries inside the answers
>> > > database table. Can someone tell me how to take same input field for
>> > > multiple entries in a loop? This because i have a varying number of
>> > > answer choices for every question. The cook book only shows how to it
>> > > indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
>> > > and so on. I tried replacing the numbers with a loop variable but then
>> > > the saveall() didnt work?
>> >
>> > > 2) i cant pass parameters from an action inside the surveys controller
>> > > to an action inside the questions controller. Can someone help me with
>> > > this? The url indicates that the parameter is being passed, but the
>> > > receiving function always gets a null.
>> >
>> > > Could someone help me with this. Thank you in advance.
>> >
>> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help
>> others
>> > > with their CakePHP related questions.
>> >
>> > > 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<cake-php%2bunsubscr...@googlegroups.com>
>> <cake-php%2bunsubscr...@googlegroups.com<cake-php%252bunsubscr...@googlegroups.com>>For
>> more options, visit this group at
>> > >http://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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<cake-php%2bunsubscr...@googlegroups.com>For
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to