Add support for radio inputs.

Created on 30 July 2024, 10 months ago

Problem/Motivation

The module currently doesn't support radio inputs, it'd be nice if it did.

Steps to reproduce

Attempt to calculate and listen to radio inputs currently doesn't work.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @codebymikey
  • Status changed to Needs review 10 months ago
  • Pipeline finished with Success
    10 months ago
    Total: 186s
    #238106
  • Pipeline finished with Success
    10 months ago
    Total: 199s
    #240819
  • 🇧🇷Brazil joaopauloc.dev

    joaopauloc.dev changed the visibility of the branch 3464607-radio-support to hidden.

  • Status changed to Needs work 9 months ago
  • 🇧🇷Brazil joaopauloc.dev

    hey @codebymikey, thanks for your contribution, appreciate that.
    but unfortunately, the changes didn't work in webforms.

    I changed the field to_divide to use radios instead numbers but the field was not rendered as expected.

    Follow the screenshot.
    Field display:

    Field settings.

  • It still says the to_divide field type is Number on the webform list, which would mean it's either not saved or there's something else going on with your instance.

    Here's an example webform config based off the example one in the module that you can use for your test:

    loan_amount:
      '#type': number
      '#title': 'Loan Amount'
      '#required': true
    interest_rate:
      '#type': number
      '#title': 'Interest Rate'
      '#required': true
    loan_term:
      '#type': radios
      '#title': 'Loan Term'
      '#options':
        1: '1 year'
        2: '2 years'
        3: '3 years'
        4: '4 years'
        5: '5 years'
      '#required': true
    result:
      '#type': form_calculation_element
      '#title': result
      '#evaluation_decimals': 2
      '#evaluation_fields': '((:loan_amount / :loan_term) + ((:interest_rate / 100) * :loan_amount)) * :loan_term'
    
  • Status changed to RTBC 9 months ago
  • 🇧🇷Brazil joaopauloc.dev

    I didn't push the webform changes. It was a local test. Whatever, I tested it again in a new instance, and worked like a charm.

    Thank you @codebymikey. This feature will be available in the next release, 1.0.4. I'm working on other tickets including one of you who opened and we plan to launch everything together.

  • 🇮🇪Ireland frankdesign

    Thanks for the MR for Radio field, which works perfectly in Webform. But it still doesn't work with Radios Other in Webform. Is it possible to work with that too?

    Thanks

  • 🇮🇪Ireland frankdesign

    Also, just to note, if a Radio button is selected by Default on page load, then the calculation does not occur (even with the MR above applied). The calculation only occurs when the radio button is changed.

    FYI - Number fields that have a Default value on page load do calculate using that Default value.

    Thanks

    F

  • 🇧🇷Brazil joaopauloc.dev

    Hey @frankdesign,
    I'll check today the issue with a radio with a default value.
    We could address the Radio other in another issue to move this one forward.

  • Status changed to Needs work about 1 month ago
  • 🇧🇷Brazil joaopauloc.dev

    Fixed the radio or any other input not triggering the calculation when the page loads with values pre-populated.
    You can't see the refresh page in the image below because it's too fast, but I set the default values to the form and the calculation works.

  • 🇧🇷Brazil joaopauloc.dev

    New task to addrees the Radio Other elements.
    https://www.drupal.org/project/calculation_fields/issues/3523735 Add support for Radios Other element Active

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

Production build 0.71.5 2024