I have a field group that contain sub field group with almost 30 fields also I have a checkbox field that I want ajaxly show hide field group accoridng checking event of it.

I have no problem with ajaxly show hide a field according to checking.but I have no idea how I can perform with fieldgroup.
Any idea?

  • Just to clarify, you want the form elements to be unloaded by default, and then loaded in via ajax if required. – Chapabu Sep 11 '12 at 11:21
  • maybe in edit of node should be loaded and in uncheck hide them(remove) – Yuseferi Sep 11 '12 at 11:23
  • According to the FAPI docs fieldsets can't have #ajax set on them so my guess is you'll need to do this manully – Clive Sep 11 '12 at 11:42
  • @Clive hi Clive,Thanks for your attention. I know I have to do it in form_alter, but I have some idea how can I perform it,maybe get groups in form $from['#groups'] and foreach of them disable sub fields or some thing like this. you have better idea? – Yuseferi Sep 11 '12 at 11:52

Have you take a look at conditionals fields, works great for node-form and can help you to build your own code.


| improve this answer | |
  • 1
    I dont want use it, I want programmically done ,although conditionals fields is powerful module but if heavy module not suitable for my small requires. – Yuseferi Sep 12 '12 at 9:29

If you want a programatic replacement for conditional fields, then you are looking for the #states attribute in the form api. https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#states Add that in a form_alter and it does the ajax for you.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.