Skip to content

Instantly share code, notes, and snippets.

@hissy hissy/view.php
Last active Jun 19, 2019

Embed
What would you like to do?
#concrete5 Check the user already submitted on express form template
<?php
defined('C5_EXECUTE') or die('Access Denied.');
$app = \Concrete\Core\Support\Facade\Facade::getFacadeApplication();
/** @var \Concrete\Core\User\User $u */
$u = $app->make(\Concrete\Core\User\User::class);
$answered = 0;
if (isset($renderer) && is_object($renderer) && $u->isRegistered()) {
$context = $renderer->getContext();
if (is_object($context)) {
/** @var \Concrete\Core\Entity\Express\Form $form */
$form = $context->getForm();
if (is_object($form)) {
/** @var \Concrete\Core\Entity\Express\Entity $entity */
$entity = $form->getEntity();
$el = new \Concrete\Core\Express\EntryList($entity);
$el->filterByAuthorUserID($u->getUserID());
$answered = $el->getResults();
}
}
}
?>
<div class="ccm-block-express-form">
<?php if ($answered) { ?>
<?php if (isset($success)) { ?>
<p><?= $success; ?></p>
<?php } else { ?>
<p><?= t('You already answered this survey. Thank you.'); ?></p>
<?php } ?>
<?php } elseif (isset($renderer)) {
?>
<div class="ccm-form">...</div>
<?php
} else {
?>
<p><?=t('This form is unavailable.'); ?></p>
<?php
} ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.