How can I add a red asterisk next to the label of each required field?
Issue #3
closed
I'd like to add a red asterisk to the right of the label text for each required field.
How can I achieve this?
Comments (6)
-
repo owner -
reporter It doesn't seem like a required class is being added to the form-group class div
<div class="form-group <!--required missing?-->"> <label class="col-form-label" for="person-given-name">Given Name</label> <input type="text" name="person[given_name]" required="required" id="person-given-name" class="form-control" value="Test 1"> </div>
Also wouldn't that css put the asterisk where I've indicated with a black asterisk?
Ideally I would like the the asterisk to be right next to the label. I can tweak that css to work if either the form-group or label has a required class.
-
repo owner Ok it looks like the plugin isn't adding the
required
class currently I'll fix that in the next release.As a current workaround try:
<style> label.required:after { content: " *"; color: red; } </style>
and with the following PHP
echo $this->Form->control('given_name', [ 'label' => ['class' => 'required'], 'required' => true ]);
-
repo owner -
assigned issue to
-
assigned issue to
-
repo owner -
repo owner - changed status to closed
Released 4.0.0.4002
- Log in to comment
I'd suggest the best way would be via css rather than messing with the CakePHP templates
Something like?
div.form-group.required:after { content:" *"; color:red; }