Bump… how hard can this be, really? or at least a “no” of some kind so I’m not stuck waiting…
Pretty sure this has gone over my head in that I don’t understand the issue, whenever I add an xProfile field to the registration form BP automatically adds a css class I can use for styling, are you not getting that?
@venutius Thanks for replying
I’m using a css framework as mentioned above, which uses its own preset CSS classes (e.g “form-control”) to standardise appearence. It’s classes I’m trying to add, not CSS for existing classes
Thanks
My only suggestion is that you can overload the registration page, this gives you access to the css for the username,password and email input fields, have you looked into that?
Yeah I know about that, thanks though. What about all the xprofile fields?
@venutius Any idea on this?
The issue is that the bp template ages run functions that auto-format the output. what you’d have to do is overload the registration page then rewrite it using the bp base functions rather than the helper functions, that way you’d get to specify your own css. But I’m not the expert here, still learning bp, there probably will be other ways.
@venutius I see what you mean now. I’m currently looking into the xprofile field object’s edit_field_html
method and passing params into that. I’ll update here if and when I find a suitable solution
That would be useful, modding the registration form is definitely on my list.
One thing to look at is BP Better Registration, this is effectively a plugin overload of the whole registration process, you could probably use that as a basis for your own registration mods.
I posted a solution here a couple mins ago but it got deleted when I edited it… odd…
Anyway, sorry @venutius I only just logged in to see your reply – I came up with the rather-inelegant solution of using XPath in the end:
$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
if( bp_get_the_profile_field_type() == 'checkbox' ){
// Buffer output for modifying checkboxes
ob_start();
// Generate the field's html
$field_type->edit_field_html();
// Store the html
$field_html = ob_get_contents();
ob_end_clean();
$dom = new DOMDocument;
$dom->loadHTML( $field_html );
$div = $dom->createElement( 'div' );
$div->setAttribute( 'class', 'col-xs-6 col-sm-4 checkbox' );
$xpath = new DOMXPath( $dom );
$labels = $xpath->query( "//label[contains(@class, 'option-label')]" );
foreach( $labels as $label ){
$div_clone = $div->cloneNode();
$label->parentNode->replaceChild( $div_clone, $label );
$div_clone->appendChild( $label );
}
echo $dom->saveHTML();
}else{
// Generate the field's html
$field_type->edit_field_html(array(
'class' => 'form-control'
));
}
The above also works for the profile edit screen
(Sorry for the double-post but I assume editing the original would have deleted it again somehow…)