⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Capitalized text grocerycrud!



Patricia Benítez
  • profile picture
  • Member

Posted 17 February 2014 - 20:16 PM

Hello everybody! :P
 
I want to know how can i capitalize a text automatically when the user is writing.
 
I know this way, 
 
$crud->callback_add_field('fieldname',array($this,'callback_to_cap'));
but i want to know other form.

 

I want to save all the text of the grocery crub in a cappital letther in the data base.
 
Im think something like 
 
 
$crud->callback_before_insert(array($this,'insert')); then cappitalized the text 

I dont have any input text im using grocery crud

 

...please help me. :(


Robert
  • profile picture
  • Member

Posted 20 February 2014 - 15:22 PM

You want only when adding the text to have it upper or on DB to ?

 

If you want only when users type do this :

$crud->callback_field('fieldname', array($this,'_callback_fieldname'));
public function _callback_fieldname($value = '', $primary_key = NULL) {
        return '<input type="text" name="fieldname" id="fieldname" style="text-transform:uppercase;">';
}

Robert
  • profile picture
  • Member

Posted 20 February 2014 - 15:31 PM

In DB to

 

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

 

function _uppercase_function($post_array)  {
$post_array['fieldname'] = strtoupper($post_array['fieldname']);
......


return $post_array;
}

Patricia Benítez
  • profile picture
  • Member

Posted 20 February 2014 - 21:36 PM

Thanks Robert....now my project is working