News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Adding classes to registration inputs

Started by newsomjk, August 21, 2013, 16:56:25 PM

Previous topic - Next topic

newsomjk

Trying to find where to add a class to registration inputs to make them match the rest of the inputs in our site. No luck so far.


Maxim Pishnyak

Link?

Also try out Firebug tool (check FAQs in this forum section).
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

newsomjk

Sites not live, so I can't give a link.

I know how to inspect it but the issue is that the only class the fields have is "required" unless I click it and then click something else, then it gains the class "invalid."

I know where the invalid class gets set, and I know where the css is for that.

However, I can't find where these fields originally get the class "required" which is what I need to find so I can change it to "required my-input-class" and searching the whole project for "required" returns about 1500 results.

Maxim Pishnyak

Quote from: newsomjk on August 21, 2013, 17:24:57 PM
Sites not live, so I can't give a link.
What happened with free shared hosting service?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

newsomjk

Viewing the site shouldn't help with this issue anyways. I just can't figure out where the fields are getting the class 'required'.

For instance, this section in administrator/components/com_virtuemart/models/userfields.php:


case 'emailaddress':
if( JFactory::getApplication()->isSite()) {
if(empty($_return['fields'][$_fld->name]['value'])) {
$_return['fields'][$_fld->name]['value'] = JFactory::getUser()->email;
}
} // vmdebug('emailaddress',$_fld);
case 'text':
case 'webaddress':


Neither email address nor text have the attribute "formcode" set in there so I don't understand how they're getting their class.

But here:

case 'password2':
$_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name . '" size="30" class="input" />'."\n";
break;


You can see the form code for a password field. Password fields are the only ones I've been able to give the class="input" to.

Maxim Pishnyak

Quote from: newsomjk on August 21, 2013, 22:13:52 PM
Viewing the site shouldn't help with this issue anyways. I just can't figure out where the fields are getting the class 'required'.
I could do much if you pretend to have better expertise then me.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

newsomjk

I'm not saying I have better expertise but as far as I know, firebug and chrome developer do not show where code gets generated from, especially if it's from a php file. All it can do is show me the styles associated with a class and changes to the DOM. If an element already has a class as soon as the page is loaded, and that class has no styles associated with it, neither Firebug nor chrome developer can point to which file that line of code came from.

If you could just say what file builds those formcodes I could find the file and edit it, it has nothing to do with viewing the site which gets pieced together by php files.

Maxim Pishnyak

Quote from: newsomjk on August 22, 2013, 18:09:05 PM
I'm not saying I have better expertise but as far as I know, firebug and chrome developer do not show where code gets generated from, especially if it's from a php file.
But they are show css classes (suffixes). Could you solve your issue with using this stuff?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

newsomjk

#8
No, I know how to see what CSS classes are attached to the fields. I can inspect it and see that the input field has the class "required" however that doesn't help in this case because it can't tell me what php file generated the code and gave it the class.

I figured it out, for anyone who needs to add classes to the registration fields:

Look in ../administrator/components/com_virtuemart/models/userfields.php around line 917 for this chunk of code:
case 'text':
case 'webaddress':

$_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="'
. $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
. '" value="' . $_return['fields'][$_fld->name]['value'] .'" '
. ($_fld->required ? ' class="required"' : '')
. ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
. $readonly . ' /> ';
break;


and replace it with this:

case 'text':
$_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="'
. $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
.'" value="' . $_return['fields'][$_fld->name]['value'] .'" '
. ($_fld->required ? ' class=" PUT WHATEVER CLASSES YOU NEED HERE required"' : ' class="PUT WHATEVER CLASSES YOU NEED HERE"')
. ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
. $readonly . ' /> ';
break;
case 'webaddress':

$_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="'
. $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
. '" value="' . $_return['fields'][$_fld->name]['value'] .'" '
. ($_fld->required ? ' class="required"' : '')
. ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
. $readonly . ' /> ';
break;

Maxim Pishnyak

You probably don't need to hack a core. You solution wouldn't resist next update. Almost everything is possible with the help of css.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart