Skip to content
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

fix #3249 カスタムコンテンツ:フィールド バリデーション不具合 #3309

Merged
merged 16 commits into from
May 8, 2024

Conversation

HungDV2022
Copy link
Collaborator

No description provided.

@HungDV2022
Copy link
Collaborator Author

レビューをお願いします。

@@ -132,11 +132,19 @@
</ul>
</div>

<?php
$emailConfirmClass = 'bca-textbox__input';
if (!empty($this->BcAdminForm->error('meta'))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HungDV2022 この判定だと、email_confirm 以外の meta でエラーが出た時にまずそうですよね。

@ryuring ryuring assigned HungDV2022 and unassigned ryuring Apr 14, 2024
@ryuring ryuring added Reviewed レビュー済 Adjusting 調整中 labels Apr 14, 2024
# Conflicts:
#	plugins/baser-core/src/Model/Validation/BcValidation.php
# Conflicts:
#	plugins/baser-core/src/Model/Validation/BcValidation.php
@@ -132,11 +132,20 @@
</ul>
</div>

<?php
$metaErrors = $entity->getError('meta');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryuring 別方法を判断しました。いかがでしょうか。

@HungDV2022 HungDV2022 assigned ryuring and unassigned HungDV2022 Apr 23, 2024
@ryuring
Copy link
Collaborator

ryuring commented Apr 29, 2024

@HungDV2022 こちらの件ですが、エラー情報が特殊であるので、エラー直後に、エラー情報を正しい状態に戻すという方針でいきたいと思います。

エラー直後のタイミングということで、CustomFieldTable に、afterMarshal メソッドを追加して対応しましょう。

    public function afterMarshal(EventInterface $event, EntityInterface $entity, ArrayObject $data, ArrayObject $options)
    {
        $metaErrors = $entity->getError('meta');
        if (isset($metaErrors['checkAlphaNumericWithJson'])) {
            $entity->setError('meta.BcCustomContent.email_confirm',  ['checkAlphaNumericWithJson' => $metaErrors['checkAlphaNumericWithJson']]);
        }
    }

@ryuring ryuring removed the Adjusting 調整中 label Apr 29, 2024
@ryuring ryuring assigned HungDV2022 and unassigned ryuring Apr 29, 2024
@HungDV2022
Copy link
Collaborator Author

@HungDV2022 こちらの件ですが、エラー情報が特殊であるので、エラー直後に、エラー情報を正しい状態に戻すという方針でいきたいと思います。

エラー直後のタイミングということで、CustomFieldTable に、afterMarshal メソッドを追加して対応しましょう。

    public function afterMarshal(EventInterface $event, EntityInterface $entity, ArrayObject $data, ArrayObject $options)
    {
        $metaErrors = $entity->getError('meta');
        if (isset($metaErrors['checkAlphaNumericWithJson'])) {
            $entity->setError('meta.BcCustomContent.email_confirm',  ['checkAlphaNumericWithJson' => $metaErrors['checkAlphaNumericWithJson']]);
        }
    }

@ryuring 勉強になりました。ありがとうございました。レビューをお願いします。

@HungDV2022 HungDV2022 assigned ryuring and unassigned HungDV2022 May 7, 2024
@ryuring
Copy link
Collaborator

ryuring commented May 8, 2024

@HungDV2022 ありがとうございます、マージします!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed レビュー済
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants