Jump to content


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


  • Please log in to reply
3 replies to this topic

#1 cletourneau

cletourneau

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationMontreal

Posted 06 October 2017 - 08: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



#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,095 posts
  • LocationLondon

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


Posted Image

#3 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,095 posts
  • LocationLondon

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....cf23354a8e3e3b7

 

Regards

Johnny


Posted Image

#4 cletourneau

cletourneau

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationMontreal

Posted 10 October 2017 - 05:31 PM

Thanks!

 

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

 

Carl






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users