⚠ In case you've missed it we are migrating 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 forum is read-only and soon will be archived. ⚠


Paul Savostin

Member Since 15 Mar 2014
Offline Last Active Feb 22 2017 10:04 PM
-----

Topics I've Started

GC & PostgreSQL

11 July 2016 - 06:58 PM

Hello. I wonder if GC supports PostgreSQL database?


Change GC config on the fly

14 November 2015 - 02:49 AM

Hi! I wonder why in GC i cant change some config values dynamically?

 

For example i need to change ckeditor configuration per controller - i guess change 'grocery_crud_text_editor_type' would be the best solution!

How u think, guys?

 


How set for one more field in different states?

19 October 2015 - 11:30 PM

I have very simple question here.

Imagine - we have table where we need to register users

Fields in table for example username, email, password

So how I could set in "add" state all three fields and in edit state only 2 fields - email and username?

I understand that we can check state somelike down bellow

 

if($state == 'add')
{
   $crud->fields('username','email','password');
}
else
{
   $crud->fields('username','email');
}

But just imagine if we have 20 fields and different only with one field!?!?

Thanks!


Please make changes in GC if i am not wrong

01 September 2015 - 07:05 PM

I found that insert_error message not working in insert state in GC datatables theme! How we see at hte attached file in update all OK!

https://github.com/s...atables-edit.js

 

row 62

success: function(data){
				$("#FormLoading").hide();
				if(data.success)
				{
					$('#crudForm').ajaxSubmit({
						dataType: 'text',
						cache: false,
						beforeSend: function(){
							$("#FormLoading").show();
						},
						success: function(result){
							$("#FormLoading").fadeOut("slow");
							data = $.parseJSON( result );
							if(data.success)
							{
								if(save_and_close)
								{
									if ($('#save-and-go-back-button').closest('.ui-dialog').length === 0) {
										window.location = data.success_list_url;
									} else {
										$(".ui-dialog-content").dialog("close");
										success_message(data.success_message);
										reload_datagrid();
									}

									return true;
								}

								$('.field_error').removeClass('field_error');

								form_success_message(data.success_message);
								reload_datagrid();
							}
							else
							{
								form_error_message(message_update_error);
							}
						},
						error: function(){

                                  //here we have message_update_error
							form_error_message( message_update_error );
						}
					});


Why GC not using inserted primary key in custom callback_insert?

28 August 2015 - 12:41 PM

Hi everyone! I face with certain situation - when using custom callback_insert function  then after u just click Save (Not insert and back to list!)

GC shows two links - edit record and back to the list like popup messages, and link "edit record" not working!

 

Explanation:

 

In GC when u use custom callback_insert and return inserted id by yourself (or true, no matter, everything except false, what means error while inserting)

present some logic if u use custom insert
 

//in my version GC 1.4.2

//if not use custom callback insert
if($this->callback_insert === null)
{
   ..... some login and after inserting creates inserted ID like

   $insert_result =  $this->basic_model->db_insert($insert_data);

   if($insert_result !== false)
   {
	$insert_primary_key = $insert_result;  
    }
    else
    {
        return false;
    }
}
else //here custom callback insert
{
    $callback_return = call_user_func($this->callback_insert, $post_data);

    if($callback_return === false)
    {
       return false;
     }

}

//finally check if inserted primary key exist
if(isset($insert_primary_key))
  return $insert_primary_key;
     else
  return true;

How we see above $inserted_id only gets in usual case and in custom callback return TRUE!

So this true casting to 1 and adds to edit link so when u click it there is always edit record with ID = 1 what terrible wrong! Why just not check what user callback return?

Something like this after calling custom function for insert:

$callback_return = call_user_func($this->callback_insert, $post_data);

if($callback_return === false)
{
       return false;
}

//here we sure that this is not true so what this is? sure it can be only ID
elseif($callback_return !== true)
{
       $insert_primary_key =  $callback_return;
}

Maybe this all already resolve in some ways before i write this. Anyway thanks for atention:)