Jump to content


MarkusD

Member Since 22 Nov 2012
Offline Last Active Jan 12 2013 09:04 PM
-----

Topics I've Started

Trying to implement the library for interdependent select lists

13 December 2012 - 03:48 PM

Hello,

I am trying to do just as it is written on the library, and I have an identical case, countries, states and cities and another table, so it should be straightforward, yet .. I am not coming on :wacko:

I have the 3 tables:

countries,

regions

towns



then I have another table called attributes which has, as foreign keys, the primary keys of each of these 3 tables, id_country, id_region, id_town

Then the names of the dropdowns are:

countries, for countries

regions, for regions

towns for cities

And also the tables for countries states and cites are interrelated the same way that it is shown in the library.

I have then the following code:

  $crud->set_relation('id_country', 'country', 'name_country'); 
  $crud->set_relation('id_region', 'regions', 'name_region');  
  $crud->set_relation('id_town', 'towns', 'name_town'); 
 
 
  $this->load->library('gc_dependent_select');
 
  
 
  $fields = array(
 
  // first field:
    'countries' => array( // first dropdown name
	  'table_name' => 'countries', // table of country
	  'title' => 'name_country', // country title
	  'relate' => null // the first dropdown hasn't a relation
    ),
 
    // second field
    'regions' => array( // second dropdown name
	  'table_name' => 'regions', // table of state
	  'title' => 'name_region', // state title
	  'id_field' => 'id_region', // table of state: primary key
	  'relate' => 'id_country', // table of state: id_pais es la foreign key de paises
	  'data-placeholder' => 'select state' //dropdown's data-placeholder:
   
    ),
   
   
    // third field. same settings
    'towns' => array(
	  'table_name' => 'towns',
	  'order_by'=>"name_town DESC",  // string. It's an optional parameter.
	  'title' => 'id: {id_town} / city : {name_town}',  // now you can use this format )))
	  'id_field' => 'id_town',
	  'relate' => 'id_region',
	  'data-placeholder' => 'select city'
    )
    );
 
 
 
  $config = array(
    'main_table' => 'atributes',
    'main_table_primary' => 'id_atribut',
    #"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/', 'atributos_Copy'/'atributs_code'
    "url" =>base_url() . '__atributos_Copia__' .'/' .'__atributos_codigo__'. '/',
  );
 
 
  $categories = new gc_dependent_select($crud, $fields, $config);
 

  //$output = $categories->render();
 
  // the second method:
  $js = $categories->get_js();
 
  $output->output.= $js;
 

I am not sure if I have interpreted the sample correctly, but what happens is that when I click on the pencil for example to update the data, it takes 3 minutes to open the panel and the select lists are not interconnected, if I move one, the other doesnt notice, also the text editor is gone, there is no formatting headers etc, so the page is very much screwed, I dont know if I have to replace the "main_table" and "table_name" by the actual name of MY tables, but I did that and made no difference.

The editor for Medium Text features are gone

06 December 2012 - 09:52 AM

SOLVED


I suspect the reason is that FTP program makes mistakes when uploading files, sometimes it misses one out of some thousands, and you are screwed as you don't know why.

so I decided to delete everything and redo. It worked.

Thank you


Markus

===================================

Hello

In one of the panels I created everything worked well, the fields that in the table were set as Medium Text, would show up in the panel as a large text field with all the smilies,and formatting icons, you know the tiny_mce etc

I have reproduced the exact same files in another web, and I am not getting the formatting icons, only an empty text field. Why is that? where is that that controls that?

I have the most basic configuration and I am only using one table in the db



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

class Al_panel_c extends CI_Controller {

function __construct()
{
parent::__construct();

$this->load->library('grocery_crud');
$this->load->library('image_moo');
}

public function index()
{
;
}

public function content()
{
$crud = new grocery_CRUD();
$crud->set_subject('Content');
$crud->set_table('content');


# ++++++++++++++++ LOAD IMAGES RESIZING ++++++++++++++++++++++++++++++++++++

$crud->set_field_upload('pic1','images'); #
$crud->set_field_upload('pic2','images'); #
$crud->set_field_upload('pic3','images'); #
$crud->set_field_upload('pic4','images'); #
$crud->set_field_upload('pic5','images'); #





$crud->callback_after_upload(array($this,'resize')); #



$output = $crud->render();

$this->_example_output($output);

}




function resize($uploader_response,$field_info, $files_to_upload)
{

$thumb_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;


$this->image_moo->load($thumb_uploaded)->resize(400,300)->save($thumb_uploaded,true);





if($this->image_moo->error) {

print $this->image_moo->display_errors();
}

return true;

}








function _example_output($output = null)

{
$this->load->view('our_template.php',$output);
}

}


In addition I am finding out that the Save and go back to list is not working.
The Save button does save, but after that, instead of the green message your data has been added ..i get an ugly unformatted message saying the same thing.

something really weird is going on here...

callback function

04 December 2012 - 02:51 PM

Hello everybody,


I am confronted with the following.

I have interdependent select lists in my webform and they work fine with JQUERY

but now, I need the same utility in the CRUD panel.

I dont know how to go about that.

I am thinking about using a callback function.., that is, when I select the first option from the first select list, then according to that previous selection, the second select lists, populates. Like I said, it works on the users interface on the web, but...how do I do that in the CRUD panel?

thank you

Different users login in?

22 November 2012 - 08:54 AM

Hello,



Would it be possible that the administration panel, where the table and rows are can have access for different users and each user just gets his own table that he can modify?

That is, what we have now is an administration page, a CRUD page where we can upload pictures, write text etc, but only for me. The scenario is that you have a website and you let other people log in, each with their different account and each of them would have access to only their own table with their own data. Of course, all can log at the same time from different places in the world.

I can imagine of course that that would be a matter of session_id, where each user gets his, and with that session_id then the specific data are retrieved for each user, I am imagining all this, but is it really feasible or it would be too difficult to do with CRUD ?


thanks