Skip to content

Lava textbox isrequired false not honored #8

Description

@zackdutra

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions