By danny_joris on
Hi all,
I have this weird issue with my theme_form_id hook in template.php of my theme. I'm trying to modify a button, but one of them moves to the top of the page after i have modified it trough template.php http://www.dannyjoris.be/files/fora/submit-button-hooks.png . I tried to remove the value from the button by using text-indent: -9999px; but this technique does not work with IE.
I modified 4 buttons all the same way, and one of them ("yourpictures_node_form") starts floating on the top of the form... all help is very welcome...
Cheers,
Danny
This is a snippet of my template.php:
/**
* Implementation of HOOK_theme().
*/
function merchantmanpub_theme(&$existing, $type, $theme, $path) {
$hooks = zen_theme($existing, $type, $theme, $path);
// Add your theme hooks like this:
/*
$hooks['hook_name_here'] = array( // Details go here );
*/
$hooks['yourpictures_node_form'] = array(
// Forms always take the form argument.
'arguments' => array('form' => NULL),
);
$hooks['faq_node_form'] = array(
// Forms always take the form argument.
'arguments' => array('form' => NULL),
);
$hooks['simplenews_block_form_1'] = array(
// Forms always take the form argument.
'arguments' => array('form' => NULL),
);
$hooks['contact_mail_page'] = array(
// Forms always take the form argument.
'arguments' => array('form' => NULL),
);
// @TODO: Needs detailed comments. Patches welcome!
return $hooks;
}
/**
* Theme override for user edit form.
*
* The function is named themename_formid.
*/
function merchantmanpub_contact_mail_page($form) {
$output = '';
// Print out the $form array to see all the elements we are working with.
//$output .= dsm($form);
// Once I know which part of the array I'm after we can change it.
// You can use the normal Form API structure to change things, like so:
// Change the Username field title to Login ID.
$form['submit']['#value'] = '';
// Make sure you call a drupal_render() on the entire $form to make sure you
// still output all of the elements (particularly hidden ones needed
// for the form to function properly.)
$output .= drupal_render($form);
return $output;
}
function merchantmanpub_simplenews_block_form_1($form) {
$output = '';
$form['submit']['#value'] = '';
$output .= drupal_render($form);
return $output;
}
function merchantmanpub_faq_node_form($form) {
$output = '';
//$output .= dsm($form);
$form['buttons']['submit']['#value'] = '';
$output .= drupal_render($form);
return $output;
}
function merchantmanpub_yourpictures_node_form($form) {
$output = '';
//$output .= dsm($form);
$form['buttons']['submit']['#value'] = '';
$output .= drupal_render($form);
return $output;
}
Comments
_
I fixed this thanks to Seutje on irc chat.
The solution for this in short term is to change the weight properties of the button:
BUT! In the end i was able to remove ALL of the button-tweaking in template.php, because Seutje reminded me of the fact that when you remove the value of a button, it will become completely useless for people with visual disabilities.
So the solution for my problem was in pure css.
I tried
text-indent: -9999px;before and (not surprisingly) it didn't work in IE.Seutje handed me the perfect css solution. Add this to your button style:
All three lines are required, even the one with "text-transform", or it won't work in IE.
Because the position of the buttons have to be set on 'absolute', it might be difficult to get your buttons in the right place. For me wrapping a div around the buttons helped with that. I managed to do that but it pretty tweaky: http://drupal.org/node/748152#comment-2746206 .
Hope this is helpful for other people.
Cheers,
Danny