scoumbourdis / grocery-crud-codeigniter-4 Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Thank for this super library!
Search filter not working for setRelationNtoN columns.
My versions: ci4, gc 2.0.1., bootstrap-v4 1.5.2.
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.
Problem routing in codeiginiter 4.3.x
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
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.
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
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.
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:
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.
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 = '';
}
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
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?.
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));
escape_str function used in
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
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);
When make a search in a table with relation ... ajax_search_list() error 500...
$state_url = base_url(implode('/',$state_url_array) . $operation);
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
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?
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:
<p>
Controller method is not found: index </p>
</div>
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?
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));
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
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;
> }
>
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.
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
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.
"Set Validation rules" in the docs says we should use 2 arguments for the function
https://www.grocerycrud.com/docs/set-validation-rules
But the grocerycrud library demands at least 3 arguments.
Too few arguments to function App\Libraries\GroceryCrud::setRule(), 2 passed in D:\xampp\htdocs\portobello\app\project\Admin.php on line 44 and at least 3 expected
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.