How to access form elements through CSS

Notice: This thread is very old.
kc2scy
Member | 22
+
0
-

Hello,
How to you reference a form or its elements through CSS?
When I create a form I normally go about this way:

$form = new Form;

however it doesn't have name to reference? I look at the documentation and it seems the constructor would take a name. but I get a error when I create the form this way:

$form = new Form('myform');

If I was able to give the form a name i'm guessing I would reference the element something like:

#myform.mypassword{
...
}

as a example.
any help would be great.

Mike

Last edited by kc2scy (2014-02-04 22:55)

jiri.pudil
Nette Blogger | 1029
+
0
-

Do you have any reason not to use CSS classes?

$form->getElementPrototype()
	->class[] = 'foo';

$input->getControlPrototype()
	->class[] = 'foo';
kc2scy
Member | 22
+
0
-

jiri.pudil wrote:

Do you have any reason not to use CSS classes?

$form->getElementPrototype()
	->class[] = 'foo';

$input->getControlPrototype()
	->class[] = 'foo';

No not at all new to the framework and just figuring things out. I'll look into this and get back to everyone how I make out.

Majkl578
Moderator | 1364
+
0
-

When using manual render in template, better would be e.g.:

{form foo}
	...
	{input bar class => 'foo-input small'}
	...
{/form}