fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Wrong label's "for" attribute #751

Closed billmn closed 12 years ago

billmn commented 12 years ago

I'm using fieldset class (but I think this is a problem of Form class) ... and I notice that labels have a wrong "for" attribute, the auto_id_prefix is double.

<label for="form_form_code" class="control-label">Code</label>
<input type="text" value="" name="code" id="form_code" required="required">
Mitchell64 commented 12 years ago

I noticed the same thing and ended up removing the auto_id_prefix by setting it to ''.

I also noticed a couple of other issues with the form output that I documented in Issue #758.

sergiigrebeniuk commented 12 years ago

Hi Davide. I can't reproduce the issue. This code:

$form = Fieldset::forge();
$form->add('code', 'Code', array('type' => 'text'));
echo $form;

outputs:

<form action="http://fuelphp.tld/index.php/issues/751" accept-charset="utf-8" method="post">

<table>
<tr>
    <td class=""><label for="form_code">Code</label></td>
    <td class=""><input type="text" id="form_code" name="code" value="" /> </td>
</tr>

</table>
</form>

Could you give us some examples?

sergiigrebeniuk commented 12 years ago

Actually I updated version and managed to reproduce this.

krtek4 commented 12 years ago

This issue is still present in the 1.1/develop branch as of today.

BTW, I was wondering what is the "meaning" of the $id parameter of the method label in the Form_Instance class. Since the 'id' key is unset from the attributes array, the label won't have any html id after the generation, and if it represents the id of the element the label is for, then there should'nt be any other treatment done on the variable.

Not sur I'm clear enough, so I'll provide some usecases :

I hope my point of view is clearer now. IHMO, the $id parameter should be renamed $for or completly deleted and it should be used as is since we don't have any information which can be used to compute the name of the referenced element.

jschreuder commented 12 years ago

Closed, will be handled by issue #839.

Savageman commented 12 years ago

I also have this problem. The prefix gets prepended twice to the for attribute of the label.

<label for="form_form_whatever"> and <input id="form_whatever">