Show more than one records on Actions View

Show multiple related records in ChronoConnect Actions View.

Overview

The issue occurred because the relation between the question and answer models was incorrectly set to 'hasOne', which only displays the first matching record.
Change the relation type from 'hasOne' to 'hasMany' for the answer model. Then, in the View template, use a loop to iterate through and display all the related answer records.

Answered
fa fasenderos 04 Feb, 2015
Hi,
I used ChronoForms for many years, but I never realized the potential of using CF with CC... good job!!

I'm trying to create an Q&A "application".
I created two Forms:
1) Questions where the data are stored in #__questions -----> | id | unique_id | user_id | question_title .......

2) Answers where the data are stored in #__answers -----> | id | unique_id | user_id | question_id | answer_title .......
So with CF (form "questions") user can create a new Question.
With CC I'm able to display all the questions and in the Custom Body List I inserted a "Reply to this Question" button with this code

<form method="post" action="index.php?option=com_chronoforms5&view=form&Itemid=178">
   <input type="hidden" name="question_id" value="{question.id}" />
   <input type="submit" value="Reply to this question" />
</form>

Clicking on this button will open the form "Answer" and with
$_POST['question.id']
I can make a relation between Questions and Answers ---> #__answers[question_id] == #__questions[id]

In CC on the Front List Settings I set the question title as View linkable.
Now the tricky part.
Clicking on the question title will open the question View with all the question data taken from #__questions + only the first corresponding answer from #__answer.
I would like to show all the answers to the selected question.


CC SETTINGS

[list]Models Title = question; Tablename = #__questions
Models Title = answer; Tablename = #__answers; Relation: hasOne; Foreign key: question_id[/list]

Thanks in advance
fa fasenderos 04 Feb, 2015
Answer
Solved.
I share the solution cause it could be useful to someone.
Simply set Answers Relation to hasMany then in the View use a foreach to loop through the array
foreach( $row['answer'] as $result) {
  echo $result[answer_title], '<br>';
}

Thanks
This topic is locked and no more replies can be posted.