8000 請問欄位怎麼只允許新增能編輯,在編輯頁就只能唯讀 · Issue #2154 · jqhph/dcat-admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

請問欄位怎麼只允許新增能編輯,在編輯頁就只能唯讀 #2154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aloha1003 opened this issue Jan 14, 2025 · 1 comment
Open

Comments

@aloha1003
Copy link

如題

if ($form->isCreating()) {
$form->text('username', 'Username')->required();
} else {
$form->display('username', 'Username');
}

我希望 username這個欄位,只有在新增的時候可以編輯,修改之後就不能編輯了
請問該怎麼寫才對
謝謝回覆

@ibrother08
Copy link
if ($form->isCreating()) {
    $form->text('username', 'Username')->required();
} else if ($form->isEditing()) {
    $form->text('username', 'Username')->disable();
}

$form->saving(function (Form $form) {
    if ($form->isEditing()) {
        $form->deleteInput(['username']);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0