I can not delete the value 0 in the datatable editor

I can not delete the value 0 in the datatable editor

gunseligunseli Posts: 14Questions: 8Answers: 0

Hi,

I am using datatable editor. My area in the picture is a decimal column. For example, it allows me to leave it blank when I enter the value 5 and then delete it. However, when I delete it after entering the value 0, the value 0 remains.

Answers

  • allanallan Posts: 63,217Questions: 1Answers: 10,415 Site admin

    What is your database (e.g. MySQL, Postgres, something else)? I've just tried to reproduce what you are seeing in this example where the age column is defined with the same set formatter that you have:

            Field::inst( 'age' )
                ->validator( Validate::numeric() )
                ->setFormatter( Format::ifEmpty(null) ),
    

    And it appears to work as expected when setting the value to be an empty string.

    Might you have set the type attribute for the input to be number? I'm wondering if the client-side is submitting the 0. Can you link to your page so I can get the full picture please?

    Thanks,
    Allan

  • gunseligunseli Posts: 14Questions: 8Answers: 0

    I am using MS SQL. This field in SQL is decimal. The problem is solved if I make this field a string.

  • gunseligunseli Posts: 14Questions: 8Answers: 0

    When I delete the value 0, it writes back 0 without even going into preSubmit

  • allanallan Posts: 63,217Questions: 1Answers: 10,415 Site admin

    Thanks for letting me know. I'll try this on Monday locally and see what is going on.

    Regards,
    Allan

  • allanallan Posts: 63,217Questions: 1Answers: 10,415 Site admin

    Hi,

    I've just tried it locally and it appears to accept empty value okay:

    What version of the Editor .NET libraries are you using please?

    Allan

This discussion has been closed.