1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is it safe to keep "name" and "id" the same in every form element?

Discussion in 'XenForo Development Discussions' started by TheBigK, Aug 13, 2015.

  1. TheBigK

    TheBigK Well-Known Member

    This could be basic; but I've not found any satisfactory answer so far. So far, I've been keeping the "name" and "id" attributes in any form in my templates the same; without any issues. I'm doing so with an aim to make the styling simpler. I THINK that the "ID" is mainly used for styling the elements, while the 'name' is the attribute required by PHP to do stuff.

    Is it safe, or a good practice to keep the name and id attributes the same in every form element?


    <input type="text" name="yo" id="yo" .....>
  2. batpool52!

    batpool52! Well-Known Member

    Most of the time, yea though I would suggest adding ctrl_ which requires user input, for example a input with name as "user_id" can have id of "ctrl_user_id".
    TheBigK likes this.

Share This Page