I want to know in JavaScript
if a particular feature is active or not.
I have a PHP
class that has some has*
methods.
So, in Twig
I do this:
{{ form_widget(form.plan.seo, {'attr': {'class': 'feature', 'data-already-active': store.premium.hasSeo}}) }}
I expect it sets data-already-active
to 0
or to 1
depending on the feature is active or not.
But the generated HTML is this if the has*
method returns true
:
<input type="checkbox" id="form_plan_seo" name="form[plan][seo]" class="feature" data-already-active="data-already-active" value="1" checked="checked">
while simply omits the data-already-active
attribute if the has*
method returns false
:
<input type="checkbox" id="form_plan_social" name="form[plan][social]" class="feature" value="1">
More, has you can see, the value of the attribute data-already-active
is not 0
or 1
nor true
or false
but is the name of the attribute itself:
data-already-active="data-already-active"
Is this normal? Have I a better way of setting this information in the checkbox
?