⚠ 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

callbackEditField not working for MySQL bool (tinyint(1))



cletourneau
  • profile picture
  • Member

Posted 06 October 2017 - 20:30 PM

I'm trying to override the default HTML when editing a MySQL boolean field (tinyint(1)).

 

I'm getting a "blank space" instead of the expected text field.

 

Here's my code

        $this->crud->setTable('my_table')
            ->setSubject('a line')
            ->callbackEditField('col_bool', function () {
                return '<input class="form-control" name="col_bool" placeholder="the boolean" />';
            })
        ;

It works for callbackAddField with the same column type.

It works for all other column types (int, decimal, varchar, date, datetime).

 

Can you confirm the bug?

 

Many thanks


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 10 October 2017 - 07:06 AM

Hello @cletourneau,

 

The bug that you are describing is pretty weird I have to say. I will have this a look and I will let you know.

Regards

Johnny


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 10 October 2017 - 11:24 AM

Hello @cletourneau,

 

I did investigate to the issue and it seems the bug is a bit more different but I can confirm that there is a bug. I did create and also fix the ticket: GC-232: Bug for callbackEditField, callbackReadField: showing nothing when the value is "0", "" or NULL

 

As you can also see from the title this only happens when the value of the data is empty, 0 or NULL. So in your case the edit row had the value of 0 and hence you were seeing this issue on tinyint. This will be released on the next version (2.3.5) but till then you can fix the issue easily with the below small change at the code:

https://gist.github.com/scoumbourdis/bd6e3143a08c63531cf23354a8e3e3b7

 

Regards

Johnny


cletourneau
  • profile picture
  • Member

Posted 10 October 2017 - 17:31 PM

Thanks!

 

I'll apply the patch while waiting for the next version...

 

Carl


rkrajnik
  • profile picture
  • Member

Posted 26 July 2020 - 21:28 PM

clone() callbacks have the same problem


rkrajnik
  • profile picture
  • Member

Posted 26 July 2020 - 21:35 PM

We're using v2.8.2... still have the same problem. Any updates?