Code Monkey home page Code Monkey logo

grocery-crud-codeigniter-4's People

Contributors

scoumbourdis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grocery-crud-codeigniter-4's Issues

setRelationNtoN search problem

Thank for this super library!

Search filter not working for setRelationNtoN columns.
My versions: ci4, gc 2.0.1., bootstrap-v4 1.5.2.

setRelationNtoN like enum list ?

Hi,

Thank for this library !

I can't get the same display as with the previous version.
I know the priority no longer exists but I didn't think it would change the general display of the Relation option.

Instead of having a list of terms on the right that I can add to the list on the left, I have the equivalent of an "enum" field.

Is this normal? Is it under development?
I admit that this option is essential for my activities.

Thank you in advance for your answer.

Question: Setting correct routes for actions

Hey Johnny,
could you add a little documentation on setting correct routes for the actions (like 'edit', 'update' etc.)?

Maybe I just didn't quite get the routes principles of CI4 with groceryCRUD, however, here is what is working for me to some extend:

$routes->get('(:segment)/add', '$1::index');
$routes->get('(:segment)/edit/(:num)', '$1::index');
$routes->match(['get', 'post'], '(:segment)/update/(:num)', '$1::index');

These routes work so far as they display the CRUD table, the edit forms, add forms and they allow updating values in the database from the 'edit' view.
However, the (JSON) success messages generated from updating datasets are simply echoed by the set_echo_and_die() function for me instead of getting embedded into the corresponding template.

Am I missing out on the concept of routing here or is this not yet implemented in the new gC version?

Thank you for the great work :)
Cheers,
Alex

Language files names on Linux

There is a problem when GC load language files.

Ex.
include(assets/grocery_crud/languages/english.php): failed to open stream: No such file or directory

This is because language files have capitalized names but GC uses names in lowercase. This fails in linux.

Throwing Exceptions in wrong namespace.

Hey Johnny,
thanks for the great work! I just implemented the current directory into cI4 this morning and so far, most things CRUD-related seem to be working.
However, throwing exceptions is not yet working, since in the GroceryCrud.php library, the namespace 'App/Libraries' is defined, which does not seem to have an 'Exception' class.
I fixed this for now by simply adding
use Exception;
after the namespace definition in the library file.

Please correct me if I'm wrong here.
Cheers
Alex

Error using set_field_upload

Hi Johnny thanks for the help,

when using set_field_upload() I'm having errors showing the image and trying to upload an image, my code is:

public function index()
    {
        $crud = new GroceryCrud();

        $crud->setTable('noticia')
            ->set_subject('Noticia')
            ->setRelation('categoria_id', 'categoria', 'descripcion')
            ->displayAs('categoria_id', 'Categoría')
            ->columns(['titulo', 'autor', 'fecha_publicacion', 'contenido', 'imagen', 'categoria_id'])
        //->addFields(['titulo', 'autor', 'fecha_publicacion', 'contenido', 'imagen', 'categoria_id'])

            ->set_field_upload('imagen', 'assets/images');

        /* ->callback_before_insert(function ($noticia_array) {
        $noticia_array['ref'] = url_title($noticia_array['titulo']);
        return $noticia_array;
        }); */

        $output = $crud->render();

        return $this->_crud_noticias_output($output);
    }

according to the indications I should not place / at the beginning
->set_field_upload('imagen', 'assets/images');

but in the browser I join public with assets, as you can see in the image, instead if I put:

->set_field_upload('imagen', '/assets/images'); the images if they appear.

error

my baseUrl parameter in App.php is: public $baseURL = 'http://localhost/noticias/public/';

and when I try to load an image I get the following errors:

error2

I wanted to report it, I don't know if it's because of lack of any configuration in my site, any help is very appreciated.

Not compatible with SQLSRV driver.

GroceryCrudModel.php appears to have an explicit query to collect field names. This breaks functionality when using CodeIgniter 4 with it's SQLSRV driver (For MS SQL).

I replaced the get_field_types_basic_table() function and also added the check_db_extra() function per a suggestion at the office Grocery Crud forum. However, now the datatables view loads but the data is coming back empty (no rows). The table in question does have data and the datatables is successfully pulling the fields corrrectly. Does another function need updating to query for data?

Here is the two functions I aforementioned that have been added to the GroceryCrudModel.php file. Please help!

function get_field_types_basic_table()
  {
        $db_field_types = array();
        //thanks to marc_s for this nice query
        $show_colums = "SELECT 
                            c.name 'field',
                            t.name 'type',
                            c.max_length 'max_length',
                            c.precision ,
                            c.scale ,
                            c.is_nullable,
                            ISNULL(i.is_primary_key, 0) 'primary_key'
                        FROM    
                            sys.columns c
                        INNER JOIN 
                            sys.types t ON c.system_type_id = t.system_type_id
                        LEFT OUTER JOIN 
                            sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
                        LEFT OUTER JOIN 
                            sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
                        WHERE
                            c.object_id = OBJECT_ID(?)
                        AND t.name <> 'sysname'";

        $rows_metadata = $this->db->query($show_colums, array($this->table_name));

        foreach ($rows_metadata->getResult() as $db_field_type) {
            
            $db_field_types[$db_field_type->field]['db_max_length'] = $db_field_type->max_length;
            $db_field_types[$db_field_type->field]['db_type']       = $db_field_type->type;
            $db_field_types[$db_field_type->field]['db_null']       = ($db_field_type->is_nullable == 1) ? true : false;
            $db_field_types[$db_field_type->field]['primary_key']   = $db_field_type->primary_key;
            $db_field_types[$db_field_type->field]['name']          = $db_field_type->field;
            $db_field_types[$db_field_type->field]['db_extra']      = $this->check_db_extra($db_field_type);
        }
        
        $results = $this->get_field_types($this->table_name);

        foreach($results as $num => $row)
        {
            $row = (array)$row;
            $results[$num] = (object)( array_merge($row, $db_field_types[$row['name']])  );
            $results[$num]->type = $results[$num]->db_type; 
        }
        
        return $results;
    }

    /**
     * Check id field is identity and assign extra properties to it
     * @param  object $db_field_type field meta-data
     * @return string extra property
     */
    public function check_db_extra($db_field_type)
    {   
        $extra = '';
        return ($db_field_type->primary_key === 1) 
                ? $extra = 'auto_increment'
                : $extra = '';
    }

Routes for add, edit, read or delete

Hi, the main interface of Grocery Crud loads well with the data I have in the table, but I have problems when trying to add, edit or read a record and I think it's because of the routes in Routes.php.

The current route is like this:

$routes->get('example', 'Examples::customers_management');

the errors it shows me are:

Controller or its method is not found: App\Controllers\Example::add
Controller or its method is not found: App\Controllers\Example::read
Controller or its method is not found: App\Controllers\Example::edit

Please, if you could just point me in the right direction.

Thank you very much.

I'm using CodeIgniter: framework-4.0.2 and this repository for Grocery Crud

addForm

Hi Johnny, thanks for the great work!,
I´m trying to implement grocery-crud on my CI4 project, but I´m having the issue for add-edit buttons, looking on the issue#6 i use ->setApiUrlPath('controller/method') and it works fine for add-edit buttons, now i can open the add form, but in this form i cant use the cancel and save button, in my routes.php im using $routes->setAutoRoute(true);

what am I doing wrong?.

strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated

PHP 8.1, NULL in a text field:

APPPATH/Libraries/GroceryCrud.php at line 262

255                     $value = $this->default_true_false_text[$value];
256                 }
257                 break;
258             case 'string':
259                 $value = $this->character_limiter($value,$this->character_limiter,"...");
260                 break;
261             case 'text':
262                 $value = $this->character_limiter(strip_tags($value),$this->character_limiter,"...");
263                 break;
264             case 'date':
265                 if(!empty($value) && $value != '0000-00-00' && $value != '1970-01-01')
266                 {
267                     list($year,$month,$day) = explode("-",$value);
268 
269                     $value = date($this->php_date_format, mktime (0, 0, 0, (int)$month , (int)$day , (int)$year));

Bug with setRelation using multiple fields

return $this->db->escape($value);

escape_str function used in

protected function set_ajax_list_queries($state_info = null)

add single quote by default as documentation
https://www.codeigniter.com/user_guide/database/queries.html?highlight=escape#db-escape

and this create a malformed query in case of a setRelation using multiple fields

Fix using instead escapeString?

Sorry for any mistakes, it's my first issue

Error in the folder "assets > grocery_crud > languages"

Hi,
I download the file from the official site for the https://github.com/scoumbourdis/grocery-crud-codeigniter-4/archive/2.0.0-BETA.zip

The installation give this error:
include " public/assets/grocery_crud/languages/english.php" : failed to open stream: No such file or directory_
Because in the 'official download folder' the files have the first letter all capital. Instead in the script all letters are transformed into lower.

Find this at line 3977 in APPPATH/Libraries/GroceryCrud.php

$this->language = strtolower($this->config->default_language);

Add action

Hi !

great library !!

I use this version for codeigniter 4 with bootstrap 4 theme.

I can't use the add_action or addAction function. Is-it not include ?

Thanks a lot !
SB

Composer support

Looks interesting, but composer support would be nice. Wouldn't it be better as a CI 4 module that we could just add as a composer dependency?

404 Page not Found

Hello

I am new on php and Codeigniter 4 with grocery-crud-codeigniter-4 and have not much knowledge om php or codeigniter yet.
I have installed which are described in Readme file but i recipient every time a message that site not found (404 Page not found)!

Jeg har installeret Codeigniter 3 med købmand 1.6.3 og der har jeg ikke nogen problemer.

Can you tell me what I'm doing wrong. Maybe it has something more Routes to do?

Here some more info:

<>404 - File Not Found
	<p>
						Controller method is not found: index					</p>
</div>
Here some more info:

Feature request: set "global" action button

Thanks for this great project!

It seems it is not possible to add new action buttons at the same level as "Export" or "Print". I would like to have this feature in order to implement an "Upload CSV File" option.

Is such a feature in plans for the foreseeable future?

strlen(): Passing null to parameter #1 ($string) of type string is deprecated

PHP Version: 8.1

APPPATH\Libraries\GroceryCrud.php at line 336

329 * @param string
330 * @param integer
331 * @param string the end character. Usually an ellipsis
332 * @return string
333 */
334 function character_limiter($str, $n = 500, $end_char = '…')
335 {
336 if (strlen($str) < $n)
337 {
338 return $str;
339 }
340
341 // a bit complicated, but faster than preg_replace with \s+
342 $str = preg_replace('/ {2,}/', ' ', str_replace(array("\r", "\n", "\t", "\x0B", "\x0C"), ' ', $str));

Some flaws in the assets folder

Hey Johnny,
great to see the project in a working state officially now :)
Here is some warning that I got from the assets:

In file
public\assets\grocery_crud\languages\arabic.php
the semicolon is missing in line 91.

In
public\assets\grocery_crud\texteditor\ckeditor\plugins\uicolor\yui\assets\yui.css
in line 6, a CSS hack is used:

*html .cke_uicolor_picker ...

This fails all validation. I would assume, that

* html .cke_uicolor_picker ...

would be the right choice, but am not sure how the rule is supposed to behave.

This however, is third-party I guess, but might still be worth a change if it does not need to be updated in the future.

Kind regards
Alex

or_where not functional

Expected behaviour:

or_where does an OR where clause

Actual Behaviour:
Error

Fix:
Model: GroceryCrudModel.php

152c152
<     	$this->builder->or_where( $key, $value, $escape);
---
>     	$this->builder->orWhere( $key, $value, $escape);

Lib: GroceryCrud.php

3382a3383
>     protected $or_where				= array();
4369a4371,4385
>      * Filter datagrid with an extra where statement.
>      *
>      * @param string $field
>      * @param string|null $value
>      * @param bool $escape
>      * @return $this
>      */
>     public function or_where(string $field, $value = null, $escape = true)
>     {
>         $this->or_where[] = array($field, $value, $escape);
> 
>         return $this;
>     }
> 

database prefix

Thank you for this excellent project and the CI4 support.

It seems that the use of a base prefix does not work for grocery-crud generated requests.

I set a prefix in the .env file :
database.default.DBPrefix = test_
(And I prefix my tables correctly)

grocery-crud seems to ignore it completely and displays a message saying that the table does not exist.

  • Grocery CRUD v2.0.1
  • CodeIgniter4 v4.1.5

XHR/404 error on ajax_list_info (Solved)

First of all, thank you for GroceryCRUD 😃

I think I found an issue: I use the index controller method as a list and if I use FlexiGrid, I get a 404/XHR error when the page tries to access ajax_list_info.

If I explicitly specify the index method, it magically works.

My workaround was to add this to Routes.php
$routes->addRedirect('/staff', '/staff/index');

It would be nice if the index() method handled this implicitly as I just wasted a day figuring this out but solved now 😆

Thanks John

Alternative to set_field_upload

Hi, I am trying to upload a file using set_field_upload but it's removed for the security reason, help me to find an alternative to it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.