Back to overview

"Mark as Done" Button

Scripting & Buttons Published on 04.11.2025

Tutorial: Creating a "Mark as Done" Button

Learn how to create a button that allows users to update a record's status to "Done" directly from a table row with a single click.

Introduction

This guide will walk you through creating a "Mark as Done" button for each row in a table view. When a user clicks this button, the record's status field will be updated in the database, and the page will refresh to show the change. This is incredibly useful for task lists, ticket systems, or any workflow where records have a status.

We will achieve this by creating a small PHP script that handles the database update and then configuring a "Custom Button" in the application settings to call this script.


Step 1: Create the Server-Side PHP Script

This PHP script is the engine of our button. It receives the record ID, performs security checks, updates the database, and sends a success or failure response back to the browser.

Create a new file named set_status_done.php inside the /custom_buttons/ directory.

Important: In the script above, you may need to change bearbeitungsstatus to the technical name of your status field and Erledigt to the value you use for "Done".

Step 2: Configure the Custom Button

Now, let's create the button in the user interface that will trigger our script.

  1. Navigate to SettingsCustom Buttons.
  2. Click on New Button.
  3. Fill in the form with the following details:
Field Value Description
Button Display Name Mark as Done The text displayed on the button.
Icon fa-check-circle A visual icon for the button.
Color Success (Green) The button's color.
URL / JavaScript custom_buttons/set_status_done.php The path to our PHP script. The system will automatically add the record and table IDs.
Display Context List View (per row) This makes the button appear on every row in the table view.
Conditional Display bearbeitungsstatus != Erledigt (Recommended) This condition hides the button if the status is already "Done", preventing redundant clicks.

Save the button. It should now appear in the actions column of your table.


Step 3: How It Works

The magic happens through a combination of your new PHP script and a global JavaScript handler already present in the application (in custom_table_view.php).

  1. When you click the "Mark as Done" button, the browser doesn't navigate away. Instead, the global JavaScript handler intercepts the click.
  2. It takes the URL from the button's href attribute (custom_buttons/set_status_done.php) and adds the correct `id`, `table_id`, and a security `sig`nature.
  3. It then makes an asynchronous request (a `fetch` call) to this complete URL.
  4. Your PHP script runs on the server, updates the database, and returns a simple JSON response: {"success": true}.
  5. The JavaScript handler receives this response. Seeing that success is true, it executes window.location.reload().
  6. The page reloads, showing the updated data. If you have a filter active (e.g., showing only "Open" items), the newly "Done" item will correctly disappear from the view.