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

Return value type error #87

Closed
pimago opened this issue May 19, 2024 · 3 comments
Closed

Return value type error #87

pimago opened this issue May 19, 2024 · 3 comments
Labels

Comments

@pimago
Copy link

pimago commented May 19, 2024

Description

When the entry form is not filled correctly I get an error page instead of the error list.
I rebuild a simplified version and still get the same error.
It was working fine a few months ago.

This is my simplified code

{# Macro to help output errors: #}
{% macro errorList(errors) %}
	 {% if errors %}
		  {{ ul(errors, { class: 'errors' }) }}
	 {% endif %}
{% endmacro %}

{# Default value for the `entry` variable: #}
{% set guestEntry = guestEntry ?? null %}

<form method="post" action="" accept-charset="UTF-8">
	 {# Hidden inputs required for the form to work: #}
	 {{ csrfInput() }}
	 {{ actionInput('guest-entries/save') }}
	 {% set path = craft.app.request.fullUri %}
	 {{ redirectInput('/' ~ path) }}
	 {{ hiddenInput('sectionHandle', 'entrants') }}

	 {# Entry properties and custom fields: #}
	 <label for="title">Name</label>
	 {{ input('text', 'title', guestEntry ? guestEntry.title, { id: 'title' }) }}
	 {{ guestEntry ? _self.errorList(guestEntry.getErrors('title')) }}

	 <label for="email">Email</label>
	 {{ input('email', 'fields[email]', guestEntry ? guestEntry.email, { id: 'email' }) }}
	 {{ guestEntry ? _self.errorList(guestEntry.getErrors('email')) }}

	 <input id="privacy" type="hidden" name="fields[plainText]" value="1">

	 <button type="submit">Publish</button>
</form>

And this is the error

TypeError: craft\guestentries\controllers\SaveController::_returnError(): Return value must be of type yii\web\Response, null returned in /var/www/html/vendor/craftcms/guest-entries/src/controllers/SaveController.php:192
Stack trace:
#0 /var/www/html/vendor/craftcms/guest-entries/src/controllers/SaveController.php(142): craft\guestentries\controllers\SaveController->_returnError(Object(craft\guestentries\models\Settings), Object(craft\elements\Entry))
#1 [internal function]: craft\guestentries\controllers\SaveController->actionIndex()
#2 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#4 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('', Array)
#5 /var/www/html/vendor/craftcms/cms/src/web/Application.php(341): yii\base\Module->runAction('guest-entries/s...', Array)
#6 /var/www/html/vendor/craftcms/cms/src/web/Application.php(642): craft\web\Application->runAction('guest-entries/s...', Array)
#7 /var/www/html/vendor/craftcms/cms/src/web/Application.php(303): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#8 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /var/www/html/web/index.php(26): yii\base\Application->run()
#10 {main}

Additional info

  • Craft version: 4.8.9
  • PHP version: 8.0.30
  • Database driver & version: MariaDB 10.3.39
  • Plugins & versions: Guest Entries 4.0.0
@pimago pimago added the bug label May 19, 2024
@pimago
Copy link
Author

pimago commented May 19, 2024

I tested this on a new Craft 5 site. I installed Guest Entries. Copied the Guest Entries usage sample code (minus the body field) to a test template and submitted an empty form. This will get me the same error as above. If I fill out the title field a new entry is created. Turning the Validate setting off or on doesn't seem to make any difference. Am I overlooking something regarding the validation?

olivierbon added a commit that referenced this issue May 21, 2024
Correct return type to match `asModelFailure()`
@olivierbon
Copy link
Member

Thanks for reporting! I just raised a PR with a fix for this.

angrybrad added a commit that referenced this issue May 23, 2024
@angrybrad
Copy link
Member

Just released 4.0.1 with this fix. Thanks, all!

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

No branches or pull requests

3 participants