Closed hansajith1998 closed 1 week ago
You can generate a link by removing id() tag. from table class without calling id() it generate <a href="">link</a>
.
Still the same, removing the ->id()
does not generate <a>
tag for me.
Well, I debugged this problem, and this is the solution.
to generate a link we need to call the route at starting before calling any other methods like id, dispatch
because this package finds button type from dynamicProperties. which store values in the same manner that we call. and it uses the first one to define type.
so try this approach
Button::add('edit')
->slot("<i data-tw-merge data-lucide='pencil' class='stroke-[2] w-3.5 h-3.5 mx-auto block text-white'></i>")
->id('edit')
->class('transition duration-200 border shadow-sm inline-flex items-center justify-center rounded-md font-medium cursor-pointer focus:ring-none focus-visible:outline-none [&:hover:not(:disabled)]:bg-opacity-90 [&:hover:not(:disabled)]:border-opacity-90 [&:not(button)]:text-center disabled:opacity-70 disabled:cursor-not-allowed bg-[#ffc107] border-opacity-5 border-[#ffca2c] text-slate-900 dark:border-warning w-8 h-[1.63rem]')
->method('get')
->route('super_admin.users.edit', ['user' => $row->id])
->can(allowed: auth()->user()->can('users.update'))
->target('_self')
->tooltip('Edit user')
// ->dispatch('edit', ['rowId' => $row->id])
Button::add('edit')
->slot("<i data-tw-merge data-lucide='pencil' class='stroke-[2] w-3.5 h-3.5 mx-auto block text-white'></i>")
->route('welcome', ['user' => $row->id])
->id('edit')
->class('transition duration-200 border shadow-sm inline-flex items-center justify-center rounded-md font-medium cursor-pointer focus:ring-none focus-visible:outline-none [&:hover:not(:disabled)]:bg-opacity-90 [&:hover:not(:disabled)]:border-opacity-90 [&:not(button)]:text-center disabled:opacity-70 disabled:cursor-not-allowed bg-[#ffc107] border-opacity-5 border-[#ffca2c] text-slate-900 dark:border-warning w-8 h-[1.63rem]')
->target('_self')
->tooltip('Edit user')
// ->dispatch('edit', ['rowId' => $row->id])
Hi @hemant-kr-meena
It worked. Thank you.
Best Regards
I have a button like this, rendering the HTML as a button (like the screenshot). The problem is it will not redirect to the edit page.. I haven't found any solution in the documentation