Reputation: 1236
I'm using yiibooster and it is really good extension for the frontend, my issues now is that I want to remove the red * that is rendered in the required fields but maintaining the required validator in the model, anyone knows how to do this????
thankss
Upvotes: 0
Views: 1757
Reputation: 1065
Red *
is adding according to your validators definition in your model. you have two options.
First in your model add On => 'scenario name'
for required validator
for the property you want. so you can control the behavior of yii-booster components because they only apply those rules which matches the scenario
of the model. for example:
array('password_repeat', 'required', 'on'=>'register'),
It will show Red *
only in register
scenario (if you set it via $model->setScenario('register');
) and in normal times no red *
will shown.
Another option for you is when you are creating the form element based on the property marked required
by validator rules in model, you can prevent that *
from showing but this way will not ignore that validation rule
and if you try to submit the form while this form field is empty you will get error from yii (because you just solve showing but in background you have your required validator). for this method, you only need to provide label
in your yii-booster
form element:
<?php echo $form->textFieldGroup($model,'textField',
array(
'wrapperHtmlOptions' => array(
'class' => 'col-sm-5',
),
'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.',
>>>>> 'label' => 'Your new value for label which will have no red *',
)
); ?>
Upvotes: 0
Reputation: 1349
<?php echo $form->textFieldGroup($model, 'username',array('label'=>Yii::t('model','Username'))); ?>
or edit line 1223 of TbActiveForm.php from
echo $this->labelEx($model, $attribute, $options['labelOptions']);
to
echo $this->label($model, $attribute, $options['labelOptions']);
Upvotes: 1
Reputation: 79073
This is an example of a label generated by a required field validator:
<label for="User_email" class="required">
Email Address <span class="required">*</span>
</label>
Therefore, you can hide it by adding this class to your site's CSS:
span.required {
display: none;
}
Upvotes: 2
Reputation: 14459
If you want to achieve what you want easily, I suggest you to do like below, which is simplest way(in my view point):
Just try to find *
selector(the ID
or CLASS
) name.(using a firebug or any inspector)
Then just do like below in your document.ready()
:
$(SELECTOR).remove();
NOTES
*
MIGHT BE CREATED DYNAMICALLYCHANGING THE CSS CLASS
IN ORDER TO DO DISPLAY:NONE
OR SOURCE MODIFICATION
Upvotes: 1