Skip to content

Instantly share code, notes, and snippets.

@uyab
Last active January 20, 2020 04:57
Show Gist options
  • Save uyab/dd8eb89821b1c5cdb9fb54c6afb8af23 to your computer and use it in GitHub Desktop.
Save uyab/dd8eb89821b1c5cdb9fb54c6afb8af23 to your computer and use it in GitHub Desktop.
Membuat field multirow di Laravolt workflow engine
  1. Buat sebuah field baru di camunda_form dengan field_type = "multirow"
  2. Edit kolom meta, tambahkan value berikut: {"form":"nama_form"}
  3. Buat sebuah file config baru di config/workflow/forms/nama_form.php
  4. Isi config file sesuai standard semantic-form, contohnya bisa dilihat di https://gist.github.com/uyab/7a1bbe0fb676027b146eef824d9ffa94
  5. Buat sebuah tabel baru untuk menyimpan field-field dari multirow tersebut

Contoh

File config/workflow/forms/kronologi.php

<?php

return [
    [
        'type' => 'text',
        'name' => 'tanggal_kronologi',
        'label' => 'Tanggal',
        'validations' => ['required'],
    ],
    [
        'type' => 'textarea',
        'name' => 'peristiwa_kronologi',
        'label' => 'Kronologi',
        'validations' => ['required'],
    ],
    [
        'type' => 'textarea',
        'name' => 'catatan_bukti_kronologi',
        'label' => 'Catatan Bukti',
        'validations' => ['required'],
    ],
];

Maka Anda perlu membuat sebuah tabel baru dengan nama kronologi dan field-fieldnya adalah: ID, timestamps, created_by, updated_by, form_id, form_type, tanggal_kronologi, peristiwa_kronologi, catatan_bukti_kronologi. Tipe data tiap kolom silakan disesuaikan sesuati kebutuhan.

Contoh script migration:

Schema::create('kronologi', function (Blueprint $table) {

    // kolom yang wajib ada
    $table->bigIncrements('id');
    $table->morphs('form');
    $table->unsignedBigInteger('created_by')->nullable();
    $table->unsignedBigInteger('updated_by')->nullable();            
    $table->timestamps();

    // kolom lain sesuai kebutuhan aplikasi
    $table->text('tanggal_kronologi');
    $table->text('peristiwa_kronologi');
    $table->text('catatan_bukti_kronologi');
    
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment