Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Is form auto_id supposed to add the for attributes to label?
  • Hello (again today ^^), I'm trying to use a form with the auto_id feature. It works great for adding the id attributeto the input field, but it doesn't add the matching for attribute to the label, so I can't see the big interest of it. ^^ My example case is trivial:
    $fieldset = Fieldset::factory('my_form', array(
        'auto_id' => true,
    ));
    $fieldset->add('name', 'My label');
    
    echo $fieldset;
    

    The input[name=name] has an id attribute, but the label doesn't have the a for attribute. How is the auto_id feature supposed to be used, I can't find it on the documentation.
  • Ok, confirmed by 2 people, I go for an issue on Github: https://github.com/fuel/core/issues/308
  • I've also noticed that the label does not get a for=""... I just assumed I was missing something.
  • If you explicitly add the id to the form (like below), the label is applied, but you're right it doesn't look like it's working for auto_id.
      $form->add('example_text',
       'Title',
       array(
        'type' => 'text',
        'value' => empty($data->example_text) ? '' : $data->example_text,
        'id' => 'example-text',
        'size' => 100,
       ),
       array(
        array('required'),
        array('trim'),
        array('max_length', 100),
        array('min_length', 3)
       )
      );
    

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion