Yii Framework Forum: How To Dynamically Show/hide Form Fields Based On Drop Down List Selection - Yii Framework Forum

Jump to content

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

How To Dynamically Show/hide Form Fields Based On Drop Down List Selection Rate Topic: -----

#1 User is offline   The Android Guy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 10-November 13

Posted 02 February 2014 - 12:42 PM

I'm relatively new to Yii, but was able to figure out how to display a drop down list form field that grabs its values (different categories) from the database. The form I'm working with is supposed to let the user create an asset, and the different asset categories are accounts, printers, servers, workstations, routers/switches, and storage.

I'm storing all of these assets in one database table, even though one could argue making a separate table for each category is more efficient. In the table, there are some fields that only apply to certain categories (an account doesn't have an IP address, but a printer doesn't have username/password). Because of that, I want to show or hide some of the fields on the create form based on which item is chosen from the category drop down.

I tried following the suggestions from this thread, but couldn't get it to work. It also doesn't make complete sense to me because the code just echoes a new field to the screen instead of actually hiding/showing a preexisting field.
0

#2 User is offline   Majid Khan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 10-January 14

Posted 03 February 2014 - 01:12 AM

Hi Android Guy!

Try this thread.

I tried disabling a textfield based on the change event of a selectbox. May be you can check your drop downlist current value and use the visible property of the form elements to be displayed.
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