This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Troiscent
Troiscent

Hello,

I use the taglist form widget in relation mode in order to add some tags to a model in a many to many relation.

Works great when my tag model only have 1 required title field, but I want to add slug to it (required too). It works perfectly when I create my tag manually, but I also want to be able to add tags using the taglist form widget with customOptions = true.

Now I have 2 required fields "title" and "slug", when I try to add a tag using the taglist, I get an error saying that "the slug field is required".

Sounds logical as I created that secondary field and set up the field as required, but how can I continue to add tags to my taglist ? Normally the slug field have a preset based on the title, but it only works when I add tag using the "core" tag form, not when I create them with taglist.

JeroenvanRensen
JeroenvanRensen

Having the same problem here, does anyone know a solution for this problem?

Last updated

mjauvin
mjauvin

Can you show some code?

m.vlad.vvv50685
m.vlad.vvv50685

Have the same issue, here is the solution i've found:

use \October\Rain\Database\Traits\Sluggable; protected $slugs = ['slug' => 'title'];

So, when we create a new record - if slug empty - it will filled value from title.

If someone have better solution - it'll be great!

Last updated

JeffGoldblum
JeffGoldblum

Using the trait is the proper way to handle it for any newly created records, even in the taglist widget. If you want to handle existing records that don't have slug values set already you'll need to run a migration to add slug values to all your existing records in order for it all to work correctly.

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.