Forums

Add a different edit link depending on value returned in list

ctrlmedia 25 Nov, 2016
Hello,
I was wondering if it was possible to have a different edit link for different records?

For example I might have different edit form for a different vehicle - so if someone clicks the Edit button on the Bike listing it will take them to a BIKE editing form. Clicking edit within the car listing will take them to the car edit form.

vehicle colour sex age Update
car red M 20 EDIT
car blue G 24 EDIT
BIKE white M 21 EDIT


I have looked through posts and don't seem to be able to see anything that really helps so if I can be pointed in the right direction that would be really helpful.

Regards
GreyHead 25 Nov, 2016
Hi ctrlmedia,

Yes you can do that but you'll need to custom build the Edit link to include the appropriate form name. You can do that in the Front List > Settings > PHP Functions box.

Bob
ctrlmedia 29 Nov, 2016
Ah I see, I think I can work that out but how do I target the edit button?

I see that I can target a record doing something like the below:
model_id.some_name:if ( $cell == '1' ) { return 'Y'; } else { return 'N'; };

but how would I target that rows EDIT button to return the new link?

Thanks again Bob
Regards
ctrlmedia 29 Nov, 2016
Hi Bob,
I think I have managed to do it in the body code of the list display. Just detected the the record and then echo'd out the necessary edit button.

Thanks for you help.
Regards
GreyHead 29 Nov, 2016
Hi ctrlmedia,

I would use the Settings > HTML box to create a custom link or button with the data I needed - something like this:
Model.my_edit_link:return "<a href='. . . &id={$row['xxx']}' >[ Edit ]</a>";


Bob
This topic is locked and no more replies can be posted.