thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

How does the slugify option works? #998

Closed wuelcas closed 7 years ago

wuelcas commented 7 years ago

Let's say I have an items table that has a slug attribute and a name attribute. In the documentation it says that to automatically generate the slug from a attribute I need to put this code in the Optional Details field when I'm creating the BREAD for the items table, in my case is this:

{
    "slugify": {
        "origin": "name", 
        "forceUpdate": true
    }
}

So I do that. I'm going to create an item and I fill the name field but I leave the slug field empty (because I understand that voyager is going to handle that automatically), but when I create the item the slug attribute is null. If I make the slug attribute NOT NULL then it throws an error of course.

So my question is how does the automatically slug generator works? Am I doing anything wrong?

PS: I check your code and I don't see anything related to generate a slug in the insertUpdateData method on the Controller.php file which is the responsable to create or update an entry. Please help, thanks

nunomsh commented 7 years ago

In the database set the slug to Not Null and UNIQUE The slug will be filled after enter the name, but you need to place the cursor in the input otherwise jquery wont catch the value. I think the function is called onFocus. It should be something like length>0 , but this I'm just guessing.

wuelcas commented 7 years ago

Thank you @nunomsh I now understand how it works and it's working properly. I think you should add this info to the documentation guys

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.