⚠ 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

"Save and go back to list"- and "Cancel"-Button not working



Damasus

Damasus
  • profile picture
  • Member

Posted 29 March 2016 - 21:38 PM

Hi guys,

 

i'm new to grocery crud and some buttons aren't working. I found many solutions for my problem but nothing worked for me.

 

My Controller looks like this:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class System_administration extends CI_Controller 
{
    
    /**
     * Constructor.
     */
    function __construct( )
    {
        parent::__construct( );
        $this->data = array('header' => array('title' => ''),
                            'top_nav' => array(),
                            'content' => array(),
                            'footer' => array()
        );
		
		$this -> load -> library( 'grocery_CRUD' );
    }//__construct()
	
	public function court()
	{
		$name = $this->session->userdata( 'name' );			
		$user = $this -> user_model -> get_by( array( 'name' => $name ) );
			
		$table_court = new grocery_CRUD();
				
		$table_court->set_subject('Tennisplätze');
		$table_court->set_table('tb_court');
		
		$table_court->add_fields( 'name', 'status', 'surface_id' );
		$table_court->edit_fields( 'name', 'status', 'surface_id' );
		
		$table_court->required_fields( 'name', 'status', 'surface_id' );
		
		$table_court->set_relation('surface_id','tb_surface','name');
		
		$table_court->display_as('name','Platzname');
		$table_court->display_as('surface_id','Platzbelag');
		
		//$table_court->unset_jquery();
		//$table_court->unset_jquery_ui();
		
		$table_court_output = $table_court->render();
		
		$this->data['header']['css_files'] = $table_court_output->css_files;
		
		$this->data['top_nav']['user'] = $user;
		
		$this->data['footer']['js_files'] = $table_court_output->js_files;
		$this->data['footer']['js_lib_files'] = $table_court_output->js_lib_files;
		$this->data['footer']['js_config_files'] = $table_court_output->js_config_files;
	
		$this->data['content']['table_court'] = $table_court_output;
		
		$this->template->set('header', 'all/header', $this->data['header']);
		$this->template->set('top_nav', 'admin/top_nav', $this->data['top_nav']);    
		$this->template->set('content', 'admin/system_administration/court', $this->data['content']);
		$this->template->set('footer', 'all/footer', $this->data['footer']);
		
		$this->template->load('template');
	}


}

My footer:

<?php if( isset( $js_files ) ): ?>

	<?php foreach($js_files as $file): ?>
		<script type="text/javascript" language="JavaScript" src="<?php echo $file; ?>?158"></script>
	<?php endforeach; ?>
	
<?php endif; ?>
    </body>
</html>

and my Header:

<!DOCTYPE html>
<html lang="de">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <title><?php echo $title; ?></title>

		<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/bootstrap.min.css" type="text/css" media="screen">
		<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/bootstrap-theme.min.css" type="text/css" media="screen">

		<?php if( isset( $css_files ) ): ?>
		
			<?php foreach( $css_files as $file ): ?>
				<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>?122" />
			<?php endforeach; ?>

		<?php endif; ?>

		
    </head>
    <body>

The dategrid loads fine. Delete, Print, Export etc. works perfect.

 

The "Save and go back to list"- and "Cancel"-Button aren't working at all. The "Save"-Button works (it performs the database action) and then it shows the message:

{"success":true,"insert_primary_key":5,"success_message":"

Your data has been successfully stored into the database. Edit Tennispl\u00e4tze<\/a> or Go back to list<\/a><\/p>","success_list_url":"http:\/\/127.0.0.1:4001\/tennisbase\/index.php\/admin\/system_administration\/court\/success\/5"}

 

I think there is a problem with javascript.. but where?

 

I hope that someone can help me and sorry for my english ;)

 

Kind regards,

Damasus


Arce13

Arce13
  • profile picture
  • Member

Posted 26 April 2016 - 10:49 AM

Hi!

 

I'm new and first of all thank you for this incredible tool I'll apreciate any help you can provide.

 

I have the same problem that Damasus has but I think the problem is related when you have a field in the table about a boolean, at least in my case if I delete this field the tool saves correctly. Please if you could fix this or give me any kind of advice it would be great.

 

Thanks


Natacha AR

Natacha AR
  • profile picture
  • Member

Posted 05 August 2016 - 19:04 PM

Hi..I have the same problem...in my case the button save and go back to the list and cancel not working, only work save, but breaks...in my project I used a bootstrap template and grocery crud bootstrap theme, maybe they are some conflict with this??

 

{"success":true,"insert_primary_key":true,"success_message":"

Sus datos han sido guardados correctamente. Editar Cursos<\/a> o Volver a la lista<\/a><\/p>","success_list_url":"http:\/\/redsocial\/index.php\/back\/control\/cursos\/success\/1"}


ShadowJack

ShadowJack
  • profile picture
  • Member

Posted 06 September 2016 - 03:39 AM

Hi..I have the same problem...in my case the button save and go back to the list and cancel not working, only work save, but breaks...in my project I used a bootstrap template and grocery crud bootstrap theme, maybe they are some conflict with this??

 

{"success":true,"insert_primary_key":true,"success_message":"

Sus datos han sido guardados correctamente. Editar Cursos<\/a> o Volver a la lista<\/a><\/p>","success_list_url":"http:\/\/redsocial\/index.php\/back\/control\/cursos\/success\/1"}

This is exactly the problem I've having as well. 'save-and-go-back' doesn't work, cancel doesn't work, save works, but gives what looks like misformatted JSON as a response.

 

Does ANYBODY have an idea what's causing this?


ShadowJack

ShadowJack
  • profile picture
  • Member

Posted 06 September 2016 - 03:46 AM

I just tried Arce13's solution, and it worked for me.  Specifically, I changed the fields defined as tinyint to smallint.  An enum would work to restrict values to '0' and '1', if a boolean flag is needed