Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form css id or css class may reflect form's class #12

Open
tomasfejfar opened this issue Mar 2, 2013 · 6 comments
Open

Form css id or css class may reflect form's class #12

tomasfejfar opened this issue Mar 2, 2013 · 6 comments

Comments

@tomasfejfar
Copy link
Owner

I wonder what @jackplug thinks about this. Is it useful to have form's class always available? Or is it unnecessary clutter?

@jackplug
Copy link

jackplug commented Mar 4, 2013

Well, if I am understanding you correctly, we do not always need a class, but it would be nice to add one based upon the function (or, to make things simpler, the layout or appearance) of a form. So default forms get the default form styling, and a form such as - for example - a filter form (which may appear in the browser horizontally) gets a class of .horizontal or something similar.

It's not great to choose non-semantic names like this, but if we choose semantic names, we end up with a lot of css selectors. Why?
Semantic names:
.filter, .search, .another-form, .selector-for-every-other-form-that-should-be-horizontal { rules }
Unsemantic names:
.horizontal { rules }

To go back to your question, we could achieve this without form classes and based upon context (put the form in a box with the class .horizontal-form') so if you want to do it this way instead, that's ok. Downside to this is that we add another container, when there is a perfectly good container already (form).

@tomasfejfar
Copy link
Owner Author

No I meant more something like:

class Shopio_Form_Product_Update will result in <form class="shopio-form-product-update"> or <form class="form-product-update">

Meaning there would be distinct CSS class for any PHP form class.

@jackplug
Copy link

jackplug commented Mar 4, 2013

So, in other words, an id, right? :)

An id is nice (as there may be times when we want to either style a specific form or easily access a specific form in JS), but being able to add a class for a type of form is really useful (see previous comment)

@tomasfejfar
Copy link
Owner Author

Muhahaha! You fell into the "id trap" :) I thought to do so first too, but then.... you can't assure that there will be only one form for each class ;)

echo $filterForm; //above
// some data foreach
echo $formForm; //bellow

resulting in duplicate ID ;)

@jackplug
Copy link

jackplug commented Mar 4, 2013

NOOOOOOooooooooooooooooo.................. :)

Good point, so it has to be a class, then. Does that mean we can still add another class, where required?

To go back to your original question, we should still probably keep the form naming class, just in case

@tomasfejfar
Copy link
Owner Author

Makes sense to use ID, after all... because it's really uncommon to use tho instances of same form on one page. And you can unset the ID if you want to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants