The result
Hello,
I needed a array with 4 radio buttons and a text input in a row.
Solutions I found on the Internet:
_Create many array and use CSS to glue them together: Not my cup of tee and couldn't make it work for me
_Create a new Question type: It was possible with Cake, but not anymore with Yii if understand this (for now)
So, here is my solution : To use javascript to take the columns and put them in one table
I think it's a really beautiful solution
So, here is how I did this
First, create many arrays question (but this solution is extendable to many other question types)
Second, edit your template.css:
Here is my code:
//Add columns heads
$("#question27 thead tr").append("<th></th>")
$("#question27 thead tr").append("<th>Comment</th>")
//Append other array row to each row of the main table
l1 = $("#question27 tr")
l2 = $("#question294 tr")
for (var i = 1; i < l1.length ; i++){
l1[i].innerHTML += (l2[i].innerHTML)
}
//Hide the other array
$("#question294").hide()
//This is just for my needs, you really don't need it : Hide the row with empty labels
var l1 = $("#question27 .answers-list .answertext")
var l3 = $("#question27 .answers-list")
for(var i=0; i < l1.length*2 - 1;i+=2){
if(l1[i].innerHTML.replace('\t','').indexOf("<input") < 2){
l3[i/2].innerHTML = ""
}
}
As you can see, the code is really quick and dirty. But I didn't have time to make a proper implementation of my idea.
But I really wanted to share it with you. Maybe one day, I will do a real tutorial with a beautiful code, but not today, sorry!