CActiveForm dependent rows

I am working on admin form which is generated by gii CRUID.

I have 3 fields in database:

  1. advertise_type (enum: Image, Embed Code) : Radio Button

  2. advertise_image (varchar) : File

  3. advertise_embed_code (text) : Textarea

Default all 3 fields are shown. I want to show only advertise_type, now when user selects ‘Image’ then show advertise_image, and if he selects ‘Embed Code’ then show advertise_embed_code.

Based on advertise_type selection validation should be fired.

What is the best way to achieve it?

this can be achieved using js code . functionality like jquery toggle :rolleyes:

firstly hidden one of them . then according the choice to toggle . (display : none|block )

in the php end just according to the advertise_type to handle (uploading etc…)

Yes i can do it using JS.

But i was checking if YII have any such default functionality? Like we can create dependent dropdown in YII without using js code.So i thought this may be also possible.