-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
Problem using the custom create dialog with multiple required fields #5616
Comments
There is a missing something. Because
|
I have actually declared it. Kirby\Panel\PageCreateDialog::$fieldTypes[] = 'writer'; But also just checked with a default |
|
I just did another test using the |
Textures and writer were first of all removed because of the link, email etc dialogs will not work. But that's also why we haven't tested those further. Declaring custom types is rather meant for plugin fields. Declaring core fields that we left out for reasons is a bit counterintuitive 😅 But would be good to narrow it down nevertheless: is it an issue with a specific field type or an issue of multiple validation rules not really being considered? |
IMHO, native form validation seems to be working in the create dialog, not fiber validation. Writer field output doesn't have a native input, so it doesn't enter validation at all. |
Fair enough. Did not take the dialog problem into consideration. I would be fine disableing those options for the create dialog. |
By the way loving computed fields! Now only the validation needs to work in the dialog. But no pressure. I will fallback to a textarea for now to make it work for editors 🙂 <?php
use Kirby\Cms\App;
return fn (App $kirby) => [
'label' => 'Answer',
'type' => 'writer',
'required' => true,
'marks' => $kirby->request()->path() == 'panel/dialogs/pages/create' ? [
'bold',
'italic',
'underline',
'strike',
'code',
] : null,
]; |
Sorry, this discussion is jumping around a lot, could one of you please summarize what the actual issue is now? |
As far as I understand; If writer field is added to create dialog which is not supported yet (adding like that), it does not apply create dialog form validation. |
Does this mean that field validation doesn't work in general in the create dialog or is it a writer-specific problem? |
@lukasbestle No, validation works as expected for supported fields in create dialog. The issue is only for writer field (create dialog already doesn't support writer field due to link dialog). I think this is not a bug for now but will be when create dialog supports the writer field. |
I think it is a bug: the dialog doesn't support the writer field, but we only disabled it because of the dialogs (and us not having nested dialogs). But I don't see a reason why the writer field validation isn't working, so that seems like a bug. I think e need to investigate
|
I still think the issue is related with that. I've checked with structure field, same issue. |
@afbora I don't understand the linked comment to be honest, I think you need to explain more detailed what you are referring to, maybe with code examples. |
@distantnative I don't know how to explain it. There is no Is it more descriptive? |
So custom validation rules don't work either with the current create dialog (writer field aside). create:
title:
label: Internal Label
fields:
- question
- answer
redirect: false
status: unlisted
sections:
fields:
type: fields
fields:
question:
label: Question
type: text
required: true
validate:
min: 10 # This one
max: 140 # And this one
answer:
label: Answer
type: text
required: true The page gets created but will not be published. |
@lukaskleinschmidt does it work for you if you add just these highlighted line? https://github.com/getkirby/kirby/pull/5687/files#diff-382775edc1b8bd986c5e0f5121f9772234c21e94711812de545e6cc5c38f858cR279-R285 |
You mean this bit of code? // create temporary form to validate the input
$form = Form::for($this->model(), ['values' => $input]);
if ($form->isInvalid() === true) {
throw new InvalidArgumentException([
'key' => 'page.changeStatus.incomplete'
]);
} It prevents the page creation. But it prevents it all the time even if the form data is actually ok. |
Description
I have a custom create dialog that uses two required fields and automatically publishes the page.
But it seems like that only the first custom field actually prevents the page creation.
Your setup
4.0.0-beta.1
Your system (please complete the following information)
The text was updated successfully, but these errors were encountered: