0

I have a field group which consists of a radio box and other fields. This field group can have multiple values. My radio box field have two options and the first is checked by default. But when I add the second value (of the field group) – my radio field has no checked option, both options are empty (in the newly added field group). Is it possible to make the first checkbox option always checked?

Here's the short video showcasing the problem: https://www.dropbox.com/s/366xt4q57ryvteu/drupal-radio-issue.mp4?dl=0

  • can you add some piece of code? – Adrian Cid Almaguer Jul 21 '16 at 16:21
  • Which one do you mean? I don't use any custom code. The functionality is built with standard CCK modules + some additional ones, but no custom code is used. – Daniel Jul 22 '16 at 6:28
0

I canno't comment to suggest you a solution, but it's probably due to the module field_group (or fieldgroup).

You should try the same content type configuration by using field_collection, because i have never faced any issue with this module.

1/ You create a new field type : field collection. You setup the field with an unlimited number of occurrences.

2/ You go to structure > field collection and add your fields.

I hope it help

Cheers.

| improve this answer | |
  • So when you yse field_collection once you add a new occurance/value the default checkbox value is checked each and every time? – Daniel Jul 22 '16 at 16:20
  • I don't understand your question mate. So my proposal is about adding a field_collection inside your content type, with the settings "number of value" = Unlimited. Then inside your field collection, you setup your checkbox as checked. So you might have our expected behavior. – Denis Kolmerschlag Jul 25 '16 at 0:36
0

The second occurrence of the field group is appearing on the form with the help of AJAX.Post AJAX the form is unable to rebuild itself which is causing the issue. You can define a custom submit handler in hook_form_alter for the particular form and rebuild the form in the custom submit handler.

 function module_name_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id =="your_form_name")
        {
        $form['actions']['submit']['#submit'][] = 'ajax_rebuild_form';
        }
}
function ajax_rebuild_form($form, &$form_state)
{
    $form_state['rebuild'] = TRUE; 
}
| improve this answer | |
  • Thank you! So I have to create a custom module and use your given code? Sorry I'm not advanced in coding. How do I target that form / content type? – Daniel Jul 26 '16 at 5:43
  • yes , you have to create a custom module. you will get the form id by print $form_id;exit; in the hook_form_alter function then use that form id to proceed as suggested – Deb Jul 26 '16 at 7:09
  • No luck :( .... – Daniel Jul 27 '16 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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