Radios are currently not supported.
As per documentation:

When referencing select lists and radio buttons in remote conditions, a 'value' condition must be used:

 '#states' => array(
    // Show the settings if 'bar' has been selected for 'foo'.
    'visible' => array(
      ':input[name="foo"]' => array('value' => 'bar'),
    ),
  ),
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zerolab created an issue. See original summary.

zerolab’s picture

Status: Active » Needs review
FileSize
2.4 KB

Attaching a patch that supports '#type' => 'radio'.
I don't think we need to support radios as a separate type as it uses 'radio' for each element internally.

itsekhmistro’s picture

Thank you for the patch. Looks great for me.

It would be also great to have a Browser test for it.

itsekhmistro’s picture

Status: Needs review » Needs work
itsekhmistro’s picture

Status: Needs work » Needs review

Updating status to recheck current tests.

itsekhmistro’s picture

Status: Needs review » Needs work

Strange but tests are failing within this patch.

There was 1 failure:

1) Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldTermTest::testCreateConfig
Article Body field is visible
Failed asserting that false is true.

/data/www/d8.m1/drupal/docroot/core/tests/Drupal/KernelTests/AssertLegacyTrait.php:31
/data/www/d8.m1/drupal/docroot/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php:112
/data/www/d8.m1/drupal/docroot/modules/custom/conditional_fields/tests/src/FunctionalJavascript/ConditionalFieldBase.php:70
/data/www/d8.m1/drupal/docroot/modules/custom/conditional_fields/tests/src/FunctionalJavascript/ConditionalFieldTermTest.php:93

FAILURES!
Tests: 3, Assertions: 19, Failures: 1.

Need to look into details later.

zrashevskaya’s picture

Made some changes to the patch. Tests are working correctly now.

zrashevskaya’s picture

drholera’s picture

Status: Needs work » Needs review
zrashevskaya’s picture

Added widget functionality to radio handler.

Topplestack’s picture

Unable to apply patch #10

Warning: require(/var/www/bfas-vm/tnr/web/modules/contrib/conditional_fields/src/Form/ConditionalFieldEditFormTab.php): failed to open stream: No such file or directory in require() (line 110 of /var/www/bfas-vm/tnr/vendor/symfony/class-loader/ApcClassLoader.php).
require() (Line: 110)
Symfony\Component\ClassLoader\ApcClassLoader->loadClass('Drupal\conditional_fields\Form\ConditionalFieldEditFormTab')
spl_autoload_call('Drupal\conditional_fields\Form\ConditionalFieldEditFormTab')
class_exists('\Drupal\conditional_fields\Form\ConditionalFieldEditFormTab') (Line: 23)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('\Drupal\conditional_fields\Form\ConditionalFieldEditFormTab') (Line: 47)
Drupal\Core\Controller\HtmlFormController->getFormObject(Object, '\Drupal\conditional_fields\Form\ConditionalFieldEditFormTab') (Line: 59)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

OlgaRabodzei’s picture

Status: Needs review » Fixed

Was fixed in the last release(2017-Apr-07). Can someone check it, please?

OlgaRabodzei’s picture

OlgaRabodzei’s picture

ChristopheDG’s picture

Radio buttons are indeed supported now for node entities (not for user entities).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.