Is there any way to override the size of a "text" date input field?

I've tried the following:

/**
* Adjust text fields so they fit in the "Find a Show" block
*/
function tw_form_views_exposed_form_alter(&$form, $form_state) {
  if ($form['#id'] == 'views-exposed-form-find-a-show-list-page-1') {
  	//dpm($form); //does not work
  	$form['submit']['#value'] = 'Find Shows'; //this works!
	$form['field_opening_dt_value']['value']['#size'] = '11'; //doesn't work (works for popup)
  	$form['field_closing_dt_value']['value']['#size'] = '11'; //doesn't work (works for popup)
  	//print '<pre>'; print_r($form); print '</pre>'; //this works
  	
  } //I'm fed up with this!
}

Comments

artofeclipse’s picture

If this is working in print_r() and dosen't work out in the html output this might be caused by another module "date" module maybe try to add .install or implement hook_enable() and inside it add

<?php
db_query("UPDATE {system} SET weight = [yournumber] WHERE name = 'yourmodulename'");
?>

where [yournumber] is an integer value that make your module to be the last module to do modification on the form output.

I hope this help you.

donpwinston’s picture

Thanks, but it still did not work. I think maybe the cck and/or date module simply ignore the #size property.

I resorted to using the CSS property "width" to override the "length" attribute of the the input tag.

Simpler is always better.

donpwinston’s picture

I've given up on this and used CSS to set the width of the <input> tags for my date input controls.

It's wrong to use CSS on form controls. The display should be left to the browser and the client's OS.

But you got to do what you got to do.

Simpler is always better.