Main Navigation

\Aksara\Laboratory\Core->addDropdown()

The documentation and cheat sheet of our framework

addDropdown() adds dropdown row actions to a CRUD table.

Purpose

addDropdown() adds dropdown row actions to a CRUD table. It lets a controller customize Aksara Core behavior while keeping the request inside the built-in CRUD, rendering, permission, validation, and response pipeline.

When to Use

Use it when the default generated interface needs extra controls, actions, filters, or layout behavior.

Reference

addDropdown(string $url, string $label, ?string $class = null, ?string $icon = null, ?array $parameter = [], bool $newTab = false, ?string $attribution = null)

Parameters

ParameterTypeRequiredDefaultDescription
$urlstringYes-Target URL or route for the action.
$labelstringYes-Human-readable label.
$class?stringNonullCSS class list.
$icon?stringNonullIcon class.
$parameter?arrayNo[]Route or query parameters passed to the action.
$newTabboolNofalseOpen target in a new browser tab when true.
$attribution?stringNonullAdditional raw attributes for the generated element.

Return Value

static

Returns the current controller instance so it can be chained with other Core methods.

Behavior

addDropdown() stores UI configuration for the generated interface. The renderer reads that configuration later and places the control in the correct table, toolbar, filter, grid, or form location.

Basic Usage

$this->addDropdown('orders/invoice', phrase('Invoice'), 'btn btn-sm btn-outline-secondary', 'mdi mdi-file-document-outline', ['order_id' => 'order_id'], true);

return $this->render('orders');

Advanced Usage

$this->addToolbar('orders/report', phrase('Report'), 'btn btn-outline-primary', 'mdi mdi-chart-bar')
    ->addButton('orders/read', phrase('View'), 'btn btn-sm btn-outline-secondary', 'mdi mdi-eye', ['order_id' => 'order_id']);

Complete Example

namespace Modules\Orders\Controllers;

use Aksara\Laboratory\Core;

class Orders extends Core
{
    public function index()
    {
        $this->setTitle(phrase('Orders'))
            ->addDropdown('orders/invoice', phrase('Invoice'), 'btn btn-sm btn-outline-secondary', 'mdi mdi-file-document-outline', ['order_id' => 'order_id'], true);

        return $this->render('orders');
    }
}

Result

The generated interface includes or changes the configured control without requiring a custom view.

Notes

  • This method is chainable and returns the current controller instance.
  • Use phrase() for visible labels so the interface remains translatable.
  • Action parameters can reference row fields so generated buttons point to the current record.

Common Mistakes

  • Hard-coding labels that should be translated with phrase().
  • Forgetting row parameters for actions that need the current record ID.

Related Methods

Available Methods

addButton addClass addDropdown addField addFilter addSubmitButton addToolbar afterDelete afterInsert afterUpdate allowPublicFormSubmission allowTokenFrom beforeDelete beforeInsert beforeUpdate columnOrder columnSize databaseConfig debug defaultValue deleteBatch deleteData distinct fieldAppend fieldOrder fieldPosition fieldPrepend fieldSize formCallback from fromSubquery getMethod gridView groupBy groupEnd groupField groupStart having havingGroupEnd havingGroupStart havingIn havingLike havingNotIn ignoreQueryString insertData insertId itemReference join like limit mergeContent mergeField modalSize notGroupStart notHavingGroupStart notHavingLike notLike offset orGroupStart orHaving orHavingGroupStart orHavingIn orHavingLike orHavingNotIn orLike orNotGroupStart orNotHavingGroupStart orNotHavingLike orNotLike orWhere orWhereIn orWhereNotIn orderBy parentModule permitUpsert render renderForm renderRead renderTable restrictOnDemo searchable select selectAvg selectCount selectMax selectMin selectSubquery selectSum serialize serializeRow setAiContext setAlias setAttribute setAutocomplete setBreadcrumb setButton setDefault setDescription setField setHeading setIcon setMessages setMethod setOptionLabel setOutput setPermission setPlaceholder setPrimary setRelation setTemplate setTheme setTitle setTooltip setUploadPath setValidation sortable table unsetColumn unsetDelete unsetField unsetMethod unsetRead unsetSelect unsetToolbar unsetTruncate unsetUpdate unsetView updateData validToken validateForm verticalSchema viewOrder where whereIn whereNotIn