Yii Framework Forum: Questionaire With Several Steps - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Questionaire With Several Steps Rate Topic: -----

#1 User is offline   Jannis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 16-December 13

Posted 30 December 2013 - 11:36 AM

I have a questionaire where the user has to go 4 steps.

MySQL-table: questionaire
fields
question1, char(80)
reply1, char(80)
question2, char(80)
reply2, char(80)
question3, char(80)
reply3, char(80)
question4, char(80)
reply4, char(80)


First view:
show question 1+2
-> answer question 1+2 -> save -> save answer 1+2 in table "questionaire"

Second view:
show question 1+2 with the answers 1+2 and ask question 3+4
-> answer question 3+4 -> save -> save answer 3+4 in table "questionaire"

Third view:
show question und replies 1-4 again to correct possible mistakes -> then save ...

Forth view:
show again all questions and replies, not editable


????????????
My question:
????????????

I don't want to use 4 actions in the questionaireController
and also not 4 views.
I only want tho use 1 controller and 1 view.

What the right Yii-way for doing this?
Modules, Components, Widgets, or what?

I wish all a Happy New Year
... it would be nice to get first answers this year, 2013 :-)
Jannis


PS.: I don't want to use javascript/ajay (I am not used with them). I want to save the answers as soon as possible in the MySQL-table.
0

#2 User is offline   Jannis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 16-December 13

Posted 30 December 2013 - 03:54 PM

Yes, of course, in reality I have two relational tables:
questions : answer (1:n) - but I wanted to make my example easy.

Who can give me some hints, which Yii-way I should take?
I have learned Yii 2 weeks ago - and reading the Yii-book of Ullman, I understood a lot but not all.
0

#3 User is offline   guaruja 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 68
  • Joined: 10-March 12

Posted 30 December 2013 - 09:53 PM

View PostJannis, on 30 December 2013 - 03:54 PM, said:

Yes, of course, in reality I have two relational tables:
questions : answer (1:n) - but I wanted to make my example easy.

Who can give me some hints, which Yii-way I should take?
I have learned Yii 2 weeks ago - and reading the Yii-book of Ullman, I understood a lot but not all.


In order to avoid multiple, redundant actions in controller you can use scenarios (in your controller), when initalizing AR in each step (i.e. $model=MyARecord("step1"); ). Using scenarios also enable you to get rid off mutiple view-files (i.e. view_step1.php, ..._step2.php) by detecting used scenario in view and structuring it for example with a switch construct (based on detected scenario) .

This certainly would be "a yii-way to do it", nevertheless there are others...

one more hint: current/previous scenario ("step") you can transport between your requests in form of a hidden field and validation rules can be defined dedicated to each scenario by using the "on" operator
0

#4 User is offline   samsonyv 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 06-December 13

Posted 06 January 2014 - 10:04 AM

Check out the wizard-behavior extension. It might be what you need and the manual is very clear.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users