Jump to content


Uppercase, Lowercase or Capitalized text on input

uppercase lowercase capitalized input

  • Please log in to reply
3 replies to this topic

#1 fdias

fdias

    grocery CRUD Addict

  • Members
  • PipPipPip
  • 93 posts

Posted 13 July 2012 - 05:32 PM

I'm sharing here what I answered Anto on a support thread.

You can use this code when you wish the input is converted to uppercase, lowercase or capitalized letters.

TO UPPERCASE:

On the crud method you use before render:

$crud->callback_add_field('fieldname',array($this,'callback_to_upper'));


Callback function:

function callback_to_upper()
{
	return '<input type="text" name="fieldname" style="text-transform:uppercase;">';
}


TO LOWERCASE:

On the crud method you use before render:

$crud->callback_add_field('fieldname',array($this,'callback_to_lower'));


Callback function:

function callback_to_lower()
{
	return '<input type="text" name="fieldname" style="text-transform:lowercase;">';
}


TO CAPITALIZE:

On the crud method you use before render:

$crud->callback_add_field('fieldname',array($this,'callback_to_cap'));


Callback function:

function callback_to_cap()
{
	return '<input type="text" name="fieldname" style="text-transform:capitalize;">';
}


Hope you like it!

Cheers.

#2 Robert

Robert

    Advanced Member

  • Members
  • PipPipPip
  • 220 posts

Posted 18 June 2013 - 08:39 AM

Thanks for this  .. i used it to.



#3 edramirez

edramirez

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts
  • LocationMetro Manila

Posted 02 November 2013 - 05:36 PM

Doing it that way would make the data appear to be in uppercase or lowercase or capitalized. But the actual data stored would not be affected. Hence, if the code were included as above to make the data uppercase but the keyboard was in lowercase, the display would be in uppercase but the data stored into the table would be in lowercase. To store the data in uppercase, we would need to add the following:

 

1. before the render:

$crud->callback_before_insert(array($this,'prepare'));
$crud->callback_before_update(array($this,'prepare'));
 

 

2. as a separate function to save as uppercase:

public function prepare($post_array)
{
$post_array['fieldname'] = strtoupper(trim($post_array['fieldname']));
return $post_array;
}
 
 
Ed


#4 lcoulon

lcoulon

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 27 January 2019 - 10:45 PM

Hello

 

Is there a way to get several input fields changed to uppercase with a single callback ?

 

This works perfectly to changed ONE field only, but calling the callbacks several time does work at all if we try to get multiple fields (textboxes) ?

 

I need to more than one field modified but do not find the proper way to do it.

 

Could someone post any example showing how to do this please ?

 

Many thanks,







Also tagged with one or more of these keywords: uppercase, lowercase, capitalized, input

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users