Looking for a simple way to get the Address attribute to show as ‘Required’ on the /register page. Apparently, some attributes just don’t have that ability. Why not? I have over-ridden the /register page and found I can shove this code into the loop which finds attributes where the ‘required’ flag was set in the Dashboard but then it spits out 2 ‘required’ labels on all the other attributes.
if ($ak->isAttributeKeyRequiredOnRegister()){echo "<div class='required'>Required...</div>";}
LOL… I’m not sure if you’re being a wise guy but that’s what I did. The problem is that now the word ‘Required’ shows twice. Once for those attributes that honor the ‘Require on Registration Form’ in the Dashboard and a second time when this code modification sees that it’s supposed to show on the Register form. I’ve solved it by wrapping things in a DIV and using CSS to hide the core’s inconsistent presentation of ‘Required’. To my thinking, these hoops are a complete and unnecessary hack. Why have a “Require on Registration Form” checkbox at all if it’s not applied consistently? I would think that requiring a person’s address might be ‘required’ in lots of contexts but perhaps I’m missing something deeper in the implementation of the ‘required’ feature.
The address attribute is considered a grouped form element. In Concrete v9 Its rendering depends on the file concrete\elements\form\grouped\bootstrap5.php
The other non grouped ones depend on concrete\elements\form\bootstrap5.php
In v8 it will be the file bootstrap3.php
Simply copy concrete\elements\form\grouped\bootstrap5.php to application\elements\form\grouped\bootstrap5.php and modify it to your liking. It will apply right away.
Take a look at how it’s done in concrete\elements\form\bootstrap5.php to see how to deal with labels and if it’s required.
I’m guessing being a multiple-input thing it creates challenges. Accessibility challenges for instance.
So maybe keeping the legend for the fieldset is the best choice and add the required there. But then is it understandable what fields are actually required? Typically, address line 1 is required but not line 2. How do we indicate that?
I’m not sure if there is a perfect solution to be honest.
And last but not least, as far as the core is concerned I think only the address attribute is grouped but third-party attributes might also use that grouping and modifying it might have unexpected results.