<?php

namespace PHPMaker2021\rdigital21;

// Page object
$SekolahEdit = &$Page;
?>
<script>
var currentForm, currentPageID;
var fsekolahedit;
loadjs.ready("head", function () {
    var $ = jQuery;
    // Form object
    currentPageID = ew.PAGE_ID = "edit";
    fsekolahedit = currentForm = new ew.Form("fsekolahedit", "edit");

    // Add fields
    var currentTable = <?= JsonEncode(GetClientVar("tables", "sekolah")) ?>,
        fields = currentTable.fields;
    if (!ew.vars.tables.sekolah)
        ew.vars.tables.sekolah = currentTable;
    fsekolahedit.addFields([
        ["npsn", [fields.npsn.visible && fields.npsn.required ? ew.Validators.required(fields.npsn.caption) : null], fields.npsn.isInvalid],
        ["nss", [fields.nss.visible && fields.nss.required ? ew.Validators.required(fields.nss.caption) : null], fields.nss.isInvalid],
        ["nama_sekolah", [fields.nama_sekolah.visible && fields.nama_sekolah.required ? ew.Validators.required(fields.nama_sekolah.caption) : null], fields.nama_sekolah.isInvalid],
        ["status", [fields.status.visible && fields.status.required ? ew.Validators.required(fields.status.caption) : null], fields.status.isInvalid],
        ["website", [fields.website.visible && fields.website.required ? ew.Validators.required(fields.website.caption) : null], fields.website.isInvalid],
        ["_email", [fields._email.visible && fields._email.required ? ew.Validators.required(fields._email.caption) : null], fields._email.isInvalid],
        ["alamat", [fields.alamat.visible && fields.alamat.required ? ew.Validators.required(fields.alamat.caption) : null], fields.alamat.isInvalid],
        ["desa_kelurahan", [fields.desa_kelurahan.visible && fields.desa_kelurahan.required ? ew.Validators.required(fields.desa_kelurahan.caption) : null], fields.desa_kelurahan.isInvalid],
        ["kecamatan", [fields.kecamatan.visible && fields.kecamatan.required ? ew.Validators.required(fields.kecamatan.caption) : null], fields.kecamatan.isInvalid],
        ["kabupaten", [fields.kabupaten.visible && fields.kabupaten.required ? ew.Validators.required(fields.kabupaten.caption) : null], fields.kabupaten.isInvalid],
        ["namaks", [fields.namaks.visible && fields.namaks.required ? ew.Validators.required(fields.namaks.caption) : null], fields.namaks.isInvalid],
        ["nipks", [fields.nipks.visible && fields.nipks.required ? ew.Validators.required(fields.nipks.caption) : null], fields.nipks.isInvalid],
        ["datetime", [fields.datetime.visible && fields.datetime.required ? ew.Validators.required(fields.datetime.caption) : null], fields.datetime.isInvalid]
    ]);

    // Set invalid fields
    $(function() {
        var f = fsekolahedit,
            fobj = f.getForm(),
            $fobj = $(fobj),
            $k = $fobj.find("#" + f.formKeyCountName), // Get key_count
            rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1,
            startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
        for (var i = startcnt; i <= rowcnt; i++) {
            var rowIndex = ($k[0]) ? String(i) : "";
            f.setInvalid(rowIndex);
        }
    });

    // Validate form
    fsekolahedit.validate = function () {
        if (!this.validateRequired)
            return true; // Ignore validation
        var fobj = this.getForm(),
            $fobj = $(fobj);
        if ($fobj.find("#confirm").val() == "confirm")
            return true;
        var addcnt = 0,
            $k = $fobj.find("#" + this.formKeyCountName), // Get key_count
            rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1,
            startcnt = (rowcnt == 0) ? 0 : 1, // Check rowcnt == 0 => Inline-Add
            gridinsert = ["insert", "gridinsert"].includes($fobj.find("#action").val()) && $k[0];
        for (var i = startcnt; i <= rowcnt; i++) {
            var rowIndex = ($k[0]) ? String(i) : "";
            $fobj.data("rowindex", rowIndex);

            // Validate fields
            if (!this.validateFields(rowIndex))
                return false;

            // Call Form_CustomValidate event
            if (!this.customValidate(fobj)) {
                this.focus();
                return false;
            }
        }

        // Process detail forms
        var dfs = $fobj.find("input[name='detailpage']").get();
        for (var i = 0; i < dfs.length; i++) {
            var df = dfs[i],
                val = df.value,
                frm = ew.forms.get(val);
            if (val && frm && !frm.validate())
                return false;
        }
        return true;
    }

    // Form_CustomValidate
    fsekolahedit.customValidate = function(fobj) { // DO NOT CHANGE THIS LINE!
        // Your custom validation code here, return false if invalid.
        return true;
    }

    // Use JavaScript validation or not
    fsekolahedit.validateRequired = <?= Config("CLIENT_VALIDATE") ? "true" : "false" ?>;

    // Dynamic selection lists
    fsekolahedit.lists.status = <?= $Page->status->toClientList($Page) ?>;
    loadjs.done("fsekolahedit");
});
</script>
<script>
loadjs.ready("head", function () {
    // Write your table-specific client script here, no need to add script tags.
});
</script>
<?php $Page->showPageHeader(); ?>
<?php
$Page->showMessage();
?>
<form name="fsekolahedit" id="fsekolahedit" class="<?= $Page->FormClassName ?>" action="<?= CurrentPageUrl(false) ?>" method="post">
<?php if (Config("CHECK_TOKEN")) { ?>
<input type="hidden" name="<?= $TokenNameKey ?>" value="<?= $TokenName ?>"><!-- CSRF token name -->
<input type="hidden" name="<?= $TokenValueKey ?>" value="<?= $TokenValue ?>"><!-- CSRF token value -->
<?php } ?>
<input type="hidden" name="t" value="sekolah">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?= (int)$Page->IsModal ?>">
<input type="hidden" name="<?= $Page->OldKeyName ?>" value="<?= $Page->OldKey ?>">
<div class="ew-edit-div"><!-- page* -->
<?php if ($Page->npsn->Visible) { // npsn ?>
    <div id="r_npsn" class="form-group row">
        <label id="elh_sekolah_npsn" for="x_npsn" class="<?= $Page->LeftColumnClass ?>"><?= $Page->npsn->caption() ?><?= $Page->npsn->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->npsn->cellAttributes() ?>>
<span id="el_sekolah_npsn">
<input type="<?= $Page->npsn->getInputTextType() ?>" data-table="sekolah" data-field="x_npsn" name="x_npsn" id="x_npsn" size="30" maxlength="255" value="<?= $Page->npsn->EditValue ?>"<?= $Page->npsn->editAttributes() ?> aria-describedby="x_npsn_help">
<?= $Page->npsn->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->npsn->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->nss->Visible) { // nss ?>
    <div id="r_nss" class="form-group row">
        <label id="elh_sekolah_nss" for="x_nss" class="<?= $Page->LeftColumnClass ?>"><?= $Page->nss->caption() ?><?= $Page->nss->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->nss->cellAttributes() ?>>
<span id="el_sekolah_nss">
<input type="<?= $Page->nss->getInputTextType() ?>" data-table="sekolah" data-field="x_nss" name="x_nss" id="x_nss" size="30" maxlength="255" value="<?= $Page->nss->EditValue ?>"<?= $Page->nss->editAttributes() ?> aria-describedby="x_nss_help">
<?= $Page->nss->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->nss->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->nama_sekolah->Visible) { // nama_sekolah ?>
    <div id="r_nama_sekolah" class="form-group row">
        <label id="elh_sekolah_nama_sekolah" for="x_nama_sekolah" class="<?= $Page->LeftColumnClass ?>"><?= $Page->nama_sekolah->caption() ?><?= $Page->nama_sekolah->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->nama_sekolah->cellAttributes() ?>>
<span id="el_sekolah_nama_sekolah">
<input type="<?= $Page->nama_sekolah->getInputTextType() ?>" data-table="sekolah" data-field="x_nama_sekolah" name="x_nama_sekolah" id="x_nama_sekolah" size="30" maxlength="255" value="<?= $Page->nama_sekolah->EditValue ?>"<?= $Page->nama_sekolah->editAttributes() ?> aria-describedby="x_nama_sekolah_help">
<?= $Page->nama_sekolah->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->nama_sekolah->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->status->Visible) { // status ?>
    <div id="r_status" class="form-group row">
        <label id="elh_sekolah_status" class="<?= $Page->LeftColumnClass ?>"><?= $Page->status->caption() ?><?= $Page->status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->status->cellAttributes() ?>>
<span id="el_sekolah_status">
<template id="tp_x_status">
    <div class="custom-control custom-radio">
        <input type="radio" class="custom-control-input" data-table="sekolah" data-field="x_status" name="x_status" id="x_status"<?= $Page->status->editAttributes() ?>>
        <label class="custom-control-label"></label>
    </div>
</template>
<div id="dsl_x_status" class="ew-item-list"></div>
<input type="hidden"
    is="selection-list"
    id="x_status"
    name="x_status"
    value="<?= HtmlEncode($Page->status->CurrentValue) ?>"
    data-type="select-one"
    data-template="tp_x_status"
    data-target="dsl_x_status"
    data-repeatcolumn="5"
    class="form-control<?= $Page->status->isInvalidClass() ?>"
    data-table="sekolah"
    data-field="x_status"
    data-value-separator="<?= $Page->status->displayValueSeparatorAttribute() ?>"
    <?= $Page->status->editAttributes() ?>>
<?= $Page->status->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->status->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->website->Visible) { // website ?>
    <div id="r_website" class="form-group row">
        <label id="elh_sekolah_website" for="x_website" class="<?= $Page->LeftColumnClass ?>"><?= $Page->website->caption() ?><?= $Page->website->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->website->cellAttributes() ?>>
<span id="el_sekolah_website">
<input type="<?= $Page->website->getInputTextType() ?>" data-table="sekolah" data-field="x_website" name="x_website" id="x_website" size="30" maxlength="255" value="<?= $Page->website->EditValue ?>"<?= $Page->website->editAttributes() ?> aria-describedby="x_website_help">
<?= $Page->website->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->website->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->_email->Visible) { // email ?>
    <div id="r__email" class="form-group row">
        <label id="elh_sekolah__email" for="x__email" class="<?= $Page->LeftColumnClass ?>"><?= $Page->_email->caption() ?><?= $Page->_email->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->_email->cellAttributes() ?>>
<span id="el_sekolah__email">
<input type="<?= $Page->_email->getInputTextType() ?>" data-table="sekolah" data-field="x__email" name="x__email" id="x__email" size="30" maxlength="255" value="<?= $Page->_email->EditValue ?>"<?= $Page->_email->editAttributes() ?> aria-describedby="x__email_help">
<?= $Page->_email->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->_email->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->alamat->Visible) { // alamat ?>
    <div id="r_alamat" class="form-group row">
        <label id="elh_sekolah_alamat" for="x_alamat" class="<?= $Page->LeftColumnClass ?>"><?= $Page->alamat->caption() ?><?= $Page->alamat->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->alamat->cellAttributes() ?>>
<span id="el_sekolah_alamat">
<input type="<?= $Page->alamat->getInputTextType() ?>" data-table="sekolah" data-field="x_alamat" name="x_alamat" id="x_alamat" size="30" maxlength="255" value="<?= $Page->alamat->EditValue ?>"<?= $Page->alamat->editAttributes() ?> aria-describedby="x_alamat_help">
<?= $Page->alamat->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->alamat->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->desa_kelurahan->Visible) { // desa_kelurahan ?>
    <div id="r_desa_kelurahan" class="form-group row">
        <label id="elh_sekolah_desa_kelurahan" for="x_desa_kelurahan" class="<?= $Page->LeftColumnClass ?>"><?= $Page->desa_kelurahan->caption() ?><?= $Page->desa_kelurahan->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->desa_kelurahan->cellAttributes() ?>>
<span id="el_sekolah_desa_kelurahan">
<input type="<?= $Page->desa_kelurahan->getInputTextType() ?>" data-table="sekolah" data-field="x_desa_kelurahan" name="x_desa_kelurahan" id="x_desa_kelurahan" size="30" maxlength="255" value="<?= $Page->desa_kelurahan->EditValue ?>"<?= $Page->desa_kelurahan->editAttributes() ?> aria-describedby="x_desa_kelurahan_help">
<?= $Page->desa_kelurahan->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->desa_kelurahan->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->kecamatan->Visible) { // kecamatan ?>
    <div id="r_kecamatan" class="form-group row">
        <label id="elh_sekolah_kecamatan" for="x_kecamatan" class="<?= $Page->LeftColumnClass ?>"><?= $Page->kecamatan->caption() ?><?= $Page->kecamatan->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->kecamatan->cellAttributes() ?>>
<span id="el_sekolah_kecamatan">
<input type="<?= $Page->kecamatan->getInputTextType() ?>" data-table="sekolah" data-field="x_kecamatan" name="x_kecamatan" id="x_kecamatan" size="30" maxlength="255" value="<?= $Page->kecamatan->EditValue ?>"<?= $Page->kecamatan->editAttributes() ?> aria-describedby="x_kecamatan_help">
<?= $Page->kecamatan->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->kecamatan->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->kabupaten->Visible) { // kabupaten ?>
    <div id="r_kabupaten" class="form-group row">
        <label id="elh_sekolah_kabupaten" for="x_kabupaten" class="<?= $Page->LeftColumnClass ?>"><?= $Page->kabupaten->caption() ?><?= $Page->kabupaten->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->kabupaten->cellAttributes() ?>>
<span id="el_sekolah_kabupaten">
<input type="<?= $Page->kabupaten->getInputTextType() ?>" data-table="sekolah" data-field="x_kabupaten" name="x_kabupaten" id="x_kabupaten" size="30" maxlength="255" value="<?= $Page->kabupaten->EditValue ?>"<?= $Page->kabupaten->editAttributes() ?> aria-describedby="x_kabupaten_help">
<?= $Page->kabupaten->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->kabupaten->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->namaks->Visible) { // namaks ?>
    <div id="r_namaks" class="form-group row">
        <label id="elh_sekolah_namaks" for="x_namaks" class="<?= $Page->LeftColumnClass ?>"><?= $Page->namaks->caption() ?><?= $Page->namaks->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->namaks->cellAttributes() ?>>
<span id="el_sekolah_namaks">
<input type="<?= $Page->namaks->getInputTextType() ?>" data-table="sekolah" data-field="x_namaks" name="x_namaks" id="x_namaks" size="30" maxlength="255" value="<?= $Page->namaks->EditValue ?>"<?= $Page->namaks->editAttributes() ?> aria-describedby="x_namaks_help">
<?= $Page->namaks->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->namaks->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->nipks->Visible) { // nipks ?>
    <div id="r_nipks" class="form-group row">
        <label id="elh_sekolah_nipks" for="x_nipks" class="<?= $Page->LeftColumnClass ?>"><?= $Page->nipks->caption() ?><?= $Page->nipks->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->nipks->cellAttributes() ?>>
<span id="el_sekolah_nipks">
<input type="<?= $Page->nipks->getInputTextType() ?>" data-table="sekolah" data-field="x_nipks" name="x_nipks" id="x_nipks" size="30" maxlength="255" value="<?= $Page->nipks->EditValue ?>"<?= $Page->nipks->editAttributes() ?> aria-describedby="x_nipks_help">
<?= $Page->nipks->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->nipks->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->datetime->Visible) { // datetime ?>
    <div id="r_datetime" class="form-group row">
        <label id="elh_sekolah_datetime" for="x_datetime" class="<?= $Page->LeftColumnClass ?>"><?= $Page->datetime->caption() ?><?= $Page->datetime->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div <?= $Page->datetime->cellAttributes() ?>>
<span id="el_sekolah_datetime">
<input type="<?= $Page->datetime->getInputTextType() ?>" data-table="sekolah" data-field="x_datetime" name="x_datetime" id="x_datetime" size="30" maxlength="100" value="<?= $Page->datetime->EditValue ?>"<?= $Page->datetime->editAttributes() ?> aria-describedby="x_datetime_help">
<?= $Page->datetime->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->datetime->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
</div><!-- /page* -->
    <input type="hidden" data-table="sekolah" data-field="x_sekolah_id" data-hidden="1" name="x_sekolah_id" id="x_sekolah_id" value="<?= HtmlEncode($Page->sekolah_id->CurrentValue) ?>">
<?php if (!$Page->IsModal) { ?>
<div class="form-group row"><!-- buttons .form-group -->
    <div class="<?= $Page->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit"><?= $Language->phrase("SaveBtn") ?></button>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" data-href="<?= HtmlEncode(GetUrl($Page->getReturnUrl())) ?>"><?= $Language->phrase("CancelBtn") ?></button>
    </div><!-- /buttons offset -->
</div><!-- /buttons .form-group -->
<?php } ?>
</form>
<?php
$Page->showPageFooter();
echo GetDebugMessage();
?>
<script>
// Field event handlers
loadjs.ready("head", function() {
    ew.addEventHandlers("sekolah");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
