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

Pat Och
Pat Och

hi there,

how to get item's id in a partial used to display a action button in a back end list column ?

my partial :

a href="<?= Backend::url('author/plugin/nameofcontroller/create_from_course', 99999) ?>" class="btn btn-default btn-xs">new session</a

where the 99999 need to be the dynamic value ( the id of the model of the list item)

seems so simple but .... spent already half day on it :-)

thanks for help

Last updated

pratyushpundir6424
pratyushpundir6424

If you use the "partial" list-column type, then you have a few variables available to you inside that partial. Namely, $record, $value and $column. What you need is $record. So your partial would be:

<a href="<?= Backend::url('author/plugin/nameofcontroller/create_from_course', $record->id) ?>" class="btn btn-default btn-xs">new session</a>

Also, make sure you set clickable = false in your columns.yaml for this column.

Last updated

david19236
david19236

Hah!

That was exactly my question to. Amazing timing :-)

Dreqnoid
Dreqnoid

Fantastic!

I played a bit with this, but is there also a way to override the row click? I want to create a publish/unpublish switch with a partial.

I want to use the switch to perform an ajax action. The problem is that I also want a (default) row click for loading the update form. Is that possible? So if i click the switch only the ajax handler and elsewhere in the row the update page?

Last updated

pratyushpundir6424
pratyushpundir6424

Dreqnoid said:

Fantastic!

I played a bit with this, but is there also a way to override the row click? I want to create a publish/unpublish switch with a partial.

You can override the row click on a particular column by setting the list property clickable=false in your list.yaml. For firing off Ajax requests you might wanna read the scripts section here http://octobercms.com/docs/ui/foundation

I want to use the switch to perform an ajax action. The problem is that I also want a (default) row click for loading the update form. Is that possible? So if i click the switch only the ajax handler and elsewhere in the row the update page?

Pat Och
Pat Och

fantastic x 2 :-) thanks a lot pratyushpundir for the response and the bonus, you save our day,

1-6 of 6

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