Closed jazztickets closed 12 years ago
Textarea,inputfield and others "must" have an ID, so there is a check if that is set and if not the ID is generated automatically... for label that is not the case.
That's not what's happening in my version of yii (1.1.10). Setting 'id'=>false removes the id attribute from the element, which is exactly what i want it to do. You can see in the tag() and renderAttributes() functions.
Why do they need an ID? Maybe for ajax, but i'm not using ajax.
I'm not sure I understand you problem... please give more information... the code you use, the generated HTML and how should it look instead.
<div class="row">
<?php echo $form->labelEx($model,'name', array('id'=>false)); ?>
<?php echo $form->textField($model,'name', array('id'=>false)); ?>
<?php echo $form->error($model,'name', array('id'=>false)); ?>
</div>
produces
<div class="row">
<label id="" for="ContactForm_name" class="required">Name <span class="required">*</span></label>
<input name="ContactForm[name]" type="text" />
<div id="" class="errorMessage" style="display:none"></div>
</div>
Notice how the input field is the only one without id="". I was hoping that setting 'id'=>false would remove it completely for
Why are you adding the id=>false to the labelEx... just remove it... and no ID will be generated...
Okay, so that fixes it for labelEx, but $form->error still has the problem.
As you can see it's not very consistent between labelEx, inputfield, and error.
for the input and error if the ID is not set they are automatically generated because that is used by the ajax validation
...
else if($htmlOptions['id']===false)
unset($htmlOptions['id']);
The question here is: why is this line of code in Yii?
I still don't see what is your problem here... the code above can be used if you don't want an ID for the input field... but the same cannot be done for the CActiveForm::error() because this is used by the ajax validation as I explained above....
In the end... why are you using CActiveForm at all... why not use the CHtml equivalents... note that the CHtml::error() do not generate the ID automatically.
Because id="" is not valid html according to W3C. That's the problem. I want to completely remove id="".
enableAjaxValidation is set to false. IDs shouldn't be needed if that's set to false.
CActiveForm can still be used if it was made more flexible. It shouldn't assume that we're always using ajax validation.
inside /framework/web/helpers/CHtml.php around line 1145, the function is missing the code that appears in textarea, inputfield and others: