Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Bug on function getName() #976

Open
Quovandius opened this issue Dec 16, 2021 · 3 comments
Open

Bug on function getName() #976

Quovandius opened this issue Dec 16, 2021 · 3 comments

Comments

@Quovandius
Copy link

Hello everyone,

I have found a very boring bug ... and after many hours to search why, I have found a solution, and may be the reason why.

When you declare a Datatable class on php, nyou can write a GetName function, as documentation said :

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'post_datatable';
    }

But, one tips is very important : you cannot use the dot character on this name.
If you use a syntax like this :

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'post.datatable';
    }

The bug occurs, and absolutely no data has been loaded .... no error ... no xhr request.

I think its because this name is use as a jquery selector, and the dot character create a mismatch with class css.
Am I wrong ?

If anyone can confirm this, I think its a good idea to add this tip on documentation :)

@Eloar
Copy link
Contributor

Eloar commented Dec 17, 2021

Haven't you got exception with msg like?

AbstractDatatable::validateName(): The result of the getName method can only contain letters, numbers, underscore and dashes.

Thats from AbstractDatatable line 321 file

@Quovandius
Copy link
Author

Oh ? no I don't see any error message. I have check my log file in var/log/dev.log and nothing appeared.

Eloar added a commit to Eloar/DatatablesBundle that referenced this issue Dec 17, 2021
- added test for invalid name validation
- changed thrown exception from `\Exception` to more specific
`\LogicException`
- updated documentation
@Eloar
Copy link
Contributor

Eloar commented Dec 17, 2021

@Quovandius this is valid issue. Apperently regex didn't match whole name and passed each time. Made change and opened PR. Maybe next version will contain fix for your issue.

Seb33300 added a commit that referenced this issue Feb 16, 2022
refs #976: fixed Datatable name validation
pokurek pushed a commit to RedWeb/DatatablesBundle that referenced this issue Oct 28, 2022
- added test for invalid name validation
- changed thrown exception from `\Exception` to more specific
`\LogicException`
- updated documentation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants