Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lava textbox isrequired false not honored #8

Open
2 tasks done
zackdutra opened this issue Oct 1, 2024 · 7 comments
Open
2 tasks done

Lava textbox isrequired false not honored #8

zackdutra opened this issue Oct 1, 2024 · 7 comments

Comments

@zackdutra
Copy link

Description

Setting isrequired to false in the lava textbox shortcode does not work.

Actual Behavior

The input always has "required" on it, whether or not false is set.

Expected Behavior

The input required attribute should change depending on what is set on the shortcode.

Steps to Reproduce

  • Add a textbox shortcode to an HTML content block, setting the value to anything, but setting isrequired to false as shown below
    {[ textbox name:'test' label:'Test' value:'test' isrequired:'false' ]}
  • Use the browser dev tools to inspect the input element and notice the required attribute still set.
    image

This will cause fields that should not be required to be required on forms.
image

In my testing, I was able to make a functional version of the Text Box by moving the assign for isrequired inside of the rock control shortcode body, such as this:

{[ rockcontrol id:'rc-{{ '' | UniqueIdentifier }}' label:'{{ label }}' showlabel:'{{ showlabel }}' controltype:'rock-text-box' isrequired:'{{ isrequired }}' validationmessage:'{{ validationmessage }}' ]}
    {% assign isrequired = isrequired | AsBoolean %}

    {% if preaddon != empty or postaddon != empty %}<div class="input-group">{% endif %}

    {% if preaddon != empty %}
        <span class="input-group-addon">{{ preaddon }}</span>
    {% endif %}

    <input name="{{ name }}" type="{{ type}}" id="{{ id }}" class="form-control {% if size != empty %}input-{{ size }}{% endif %} {% if width != empty %}input-width-{{ width }}{% endif %}" value="{{ value }}" {% if isrequired == true %}required{% endif %} {{ additionalattributes }}>

    {% if postaddon != empty %}
        <span class="input-group-addon">{{ postaddon }}</span>
    {% endif %}

    {% if preaddon != empty or postaddon != empty %}</div>{% endif %}

{[ endrockcontrol ]}

Issue Confirmation

  • Perform a search on the Github Issues to see if your bug or enhancement is already reported.
  • Try to reproduce the problem on a fresh install or on the demo site.

Rock Version

16.6

@zackdutra zackdutra added the bug Something isn't working label Oct 1, 2024
@bradencohen
Copy link

Hey Zack!

We have some ideas as to what this could be, could you tell us what Lava engine you're running so we can more thoroughly validate our fix?

@zackdutra
Copy link
Author

Hey @bradencohen this is on Fluid, thanks!

@jonedmiston
Copy link
Member

@zackdutra can you confirm that this is still not working for you. We've tested this and it seems to be working correctly.

@jonedmiston jonedmiston added unable to reproduce and removed bug Something isn't working labels Jan 3, 2025
@zackdutra
Copy link
Author

Screenshot 2025-01-04 at 10 13 06 AM

Hey @jonedmiston to confirm, this lava {[ textbox name:'test' label:'Test' value:'test' isrequired:'false' ]} renders the textbox above with a required attribute set.

This was originally reported while doing local development, but this test today was on our production instance.

@jonedmiston
Copy link
Member

@zackdutra odd. I've tested your markup https://prealpha.rocksolidchurchdemo.com/page/853 on three servers and they all return the correct results. You can see that here on the pre-alpha server: https://prealpha.rocksolidchurchdemo.com/page/853

Is there anything in your Lava configuration that is different or unique?

@zackdutra
Copy link
Author

Hey Jon, I've inspected the content blocks between the two, the Text Box shortcode, and the Rock Control shortcode between our production server and the prealpha site, and they appear identical. Additionally, I ran the two through ChatGPT and it thinks they're identical in content. I'm not sure how to explain the difference either.

@pbassham
Copy link

pbassham commented Jan 9, 2025

I see this issue too.

I did some work to reproduce it.

It looks like the issue is that the {{ blockContent }} when inside of the {[ rockcontrol ]} block shortcode is a different scope. So the variable isrequired is no longer a true Boolean value inside of the rockcontrol shortcode.

I modified the {[ textbox ]} markup to test these values by printing them using ToJSON, which puts quotes around strings, but not around true boolean values.

Inside of the rockcontrol block the isrequired variable is a string again, even though it was converted AsBoolean in the first line, outside of the rockcontrol block.
image

Here is the shortcode i used:
{[ textbox name:'lastname' label:'List Id' isrequired:'true' additionalattributes:'placeholder="22780884-b6fa-4d4a-a0fc-aa3981cd8d60"']}

When setting isrequired to true, it works. This is what my test code renders:
image

But when setting it to false, it gets evaluated as true. This is what my test code renders:
image

Also, this doesnt seem to just affect the textbox shortcode, but all of the boolean values that are wrapped in the {[ rockcontrol ]} block shortcode. Currency, datepicker, etc.

Also, just to note, the required is set correctly on the div with the form-group class. It is the actual <input> field that doesnt update correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants