Undefined array key 1

Permalink Browser Info Environment
Hi

Just starting to use v9 of Concrete and PHP 8.
Get the attached error, seems to be related to adding a select field.

Any ideas how to avoid it?
Thanks
Dave

1 Attachment

Type: Ticket
Status: In Progress
madesimplemedia
View Replies:
ramonleenders replied on at Permalink Reply
ramonleenders
Hi Dave,

Did you use the double semicolon in your input?

concrete5_old :: Concrete5 CMS 5.6
concrete5_legacy :: Concrete5 CMS 5.7
concretecms :: ConcreteCMS 9.0
wordpress :: WordPress

If not, these are needed to have a key/value pair. So everything at the start will be your key, behind will be the value.

Kind regards
Ramon
madesimplemedia replied on at Permalink Reply
madesimplemedia
Hi Ramon

Thanks, I hadn't done that so I have now done that and successfully created the test block.

However, when I add it to the page I get this:

Undefined variable $slct

Details

/home/templatev9/public_html/application/blocks/test_block/form.php(6): Whoops\Exception\ErrorException->null
/home/templatev9/public_html/application/blocks/test_block/form.php(6): Whoops\Run->handleError
/home/templatev9/public_html/concrete/src/Block/View/BlockView.php(380): null->include
/home/templatev9/public_html/application/blocks/test_block/add.php(2): Concrete\Core\Block\View\BlockView->inc
/home/templatev9/public_html/concrete/src/Block/View/BlockView.php(267): null->include
/home/templatev9/public_html/concrete/src/View/AbstractView.php(164): Concrete\Core\Block\View\BlockView->renderViewContents
...
madesimplemedia replied on at Permalink Reply
madesimplemedia
Ah this seems to be a PHP 8 thing. Have you got it working on 8 yet, if not I'll stick to 7?
ramonleenders replied on at Permalink Reply
ramonleenders
Hey Dave,

Looks like somewhere the generated code messed up. Can you take a look in your generated view file?

$slct

This variable seems not to exist, but it should if you named it like this? Not sure what happened there...

Kind regards
Ramon
madesimplemedia replied on at Permalink Reply
madesimplemedia
Here you go, works in PHP7.4:

<?php defined("C5_EXECUTE") or die("Access Denied."); ?>
<?php if (trim($slct) != "") { ?>

<?php switch($slct) {
case "yes":
// ENTER MARKUP HERE FOR FIELD "Select" : CHOICE "Yes"
break;
case "no":
// ENTER MARKUP HERE FOR FIELD "Select" : CHOICE "No"
break;
case "not_sure":
// ENTER MARKUP HERE FOR FIELD "Select" : CHOICE "Not Sure"
break;
} ?><?php } ?>
<?php if (!empty($lnk) && ($lnk_c = Page::getByID($lnk)) && !$lnk_c->error && !$lnk_c->isInTrash()) {
?>
<?php echo '<a href="' . $lnk_c->getCollectionLink() . '">' . (isset($lnk_text) && trim($lnk_text) != "" ? $lnk_text : $lnk_c->getCollectionName()) . '</a>';
?><?php } ?>
<?php if ($img) { ?>
<img src="<?php echo $img->getURL(); ?>" alt="<?php echo $img->getTitle(); ?>"/><?php } ?>
<?php if (isset($fle) && $fle !== false) { ?>
<a href="<?php echo $fle->urls["relative"]; ?>">
<?php echo isset($fle_title) && trim($fle_title) != "" ? h($fle_title) : $fle->getTitle(); ?>
</a><?php } ?>
<?php if (isset($txtar) && trim($txtar) != "") { ?>
<?php echo h($txtar); ?><?php } ?>
<?php if (isset($txtbx) && trim($txtbx) != "") { ?>
<?php echo h($txtbx); ?><?php } ?>
ramonleenders replied on at Permalink Reply
ramonleenders
What happens if you change

<?php if (trim($slct) != "") { ?>

To

<?php if (isset($slct) && trim($slct) != "") { ?>

And

<?php if ($img) { ?>

To

<?php if (isset($img) && $img) { ?>

Does that give you an error elsewhere or does it work directly?

Kind regards
Ramon
madesimplemedia replied on at Permalink Reply
madesimplemedia
Same issue, it seems the issue is in form.php, doesn't like $slct:
<?php echo $form->select($view->field('slct'), $slct_options, $slct, []); ?>
ramonleenders replied on at Permalink Reply
ramonleenders
OK, stick with PHP7 for now then. I will have to dive deeper at some point in time when I have the time to do so! Probably it is the same in the form.php file where it needs an "isset($slct)" as well..

Kind regards
Ramon
madesimplemedia replied on at Permalink Reply
madesimplemedia
OK thanks Ramon
kspitzley replied on at Permalink Reply
kspitzley
I'm also having this issue! I'll downgrade to 7 for now and see if it helps too.
kspitzley replied on at Permalink Reply
kspitzley
Actually I take it back - I was having trouble creating the block because I thought setting the array key values was optional, but when i do set them, I am able to add my block to a page just fine. I'm running Concrete v9.3.1 on PHP 8.1

concrete5 Environment Information

# Concrete Version
Core Version - 9.1.3
Version Installed - 9.1.3
Database Version - 20220908074900

# Hostname
eris.uksrv.co.uk

# Environment
production

# Database Information
Version: 10.3.38-MariaDB-log-cll-lve
SQL Mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

# Concrete Packages
Block Designer (4.1.1), Block Designer Pro (4.1.1)

# Concrete Overrides
blocks/autonav/templates/main_nav/view.php, blocks/autonav/templates/main_nav, blocks/autonav/templates/sub_nav/view.php, blocks/autonav/templates/sub_nav, blocks/autonav/templates, blocks/autonav, blocks/msm_logo/controller.php, blocks/msm_logo/icon.png, blocks/msm_logo/db.xml, blocks/msm_logo/view.php, blocks/msm_logo/config.json, blocks/msm_logo/add.php, blocks/msm_logo/composer.php, blocks/msm_logo/edit.php, blocks/msm_logo/form.php, blocks/msm_logo, blocks/file/view.php, blocks/file, blocks/msm_faq/add.php, blocks/msm_faq/config.json, blocks/msm_faq/controller.php, blocks/msm_faq/db.xml, blocks/msm_faq/view.php, blocks/msm_faq/icon.png, blocks/msm_faq/view.css, blocks/msm_faq/edit.php, blocks/msm_faq/composer.php, blocks/msm_faq/view.js, blocks/msm_faq/form.php, blocks/msm_faq/auto.js, blocks/msm_faq, blocks/msm_hr/add.php, blocks/msm_hr/config.json, blocks/msm_hr/db.xml, blocks/msm_hr/edit.php, blocks/msm_hr/form.php, blocks/msm_hr/composer.php, blocks/msm_hr/icon.png, blocks/msm_hr/view.php, blocks/msm_hr/controller.php, blocks/msm_hr, blocks/form/controller.phpOLD, blocks/form/templates/no_labels/view.php, blocks/form/templates/no_labels, blocks/form/templates, blocks/form, blocks/msm_image_with_copy/add.php, blocks/msm_image_with_copy/icon.png, blocks/msm_image_with_copy/form.php, blocks/msm_image_with_copy/composer.php, blocks/msm_image_with_copy/config.json, blocks/msm_image_with_copy/controller.php, blocks/msm_image_with_copy/edit.php, blocks/msm_image_with_copy/db.xml, blocks/msm_image_with_copy/view.php, blocks/msm_image_with_copy, blocks/msm_accordion/auto.js, blocks/msm_accordion/composer.php, blocks/msm_accordion/css_form/repeatable-ft.form.css, blocks/msm_accordion/css_form, blocks/msm_accordion/js_form/handlebars-helpers.js, blocks/msm_accordion/js_form/handlebars-v4.0.4.js, blocks/msm_accordion/js_form, blocks/msm_accordion/form.php, blocks/msm_accordion/icon.png, blocks/msm_accordion/view.php, blocks/msm_accordion/add.php, blocks/msm_accordion/db.xml, blocks/msm_accordion/config.json, blocks/msm_accordion/edit.php, blocks/msm_accordion/controller.php, blocks/msm_accordion, blocks/google_api_map/form.php, blocks/google_api_map/view.css, blocks/google_api_map/icon.png, blocks/google_api_map/config.json, blocks/google_api_map/controller.php, blocks/google_api_map/composer.php, blocks/google_api_map/db.xml, blocks/google_api_map/edit.php, blocks/google_api_map/view.php, blocks/google_api_map/add.php, blocks/google_api_map, blocks/msm_cta/db.xml, blocks/msm_cta/edit.php, blocks/msm_cta/controller.php, blocks/msm_cta/add.php, blocks/msm_cta/config.json, blocks/msm_cta/form.php, blocks/msm_cta/view.php, blocks/msm_cta/composer.php, blocks/msm_cta/icon.png, blocks/msm_cta, blocks/msm_ajax_slider/form.php, blocks/msm_ajax_slider/js_form/handlebars-helpers.js, blocks/msm_ajax_slider/js_form/handlebars-v4.0.4.js, blocks/msm_ajax_slider/js_form, blocks/msm_ajax_slider/db.xml, blocks/msm_ajax_slider/edit.php, blocks/msm_ajax_slider/composer.php, blocks/msm_ajax_slider/view.php, blocks/msm_ajax_slider/icon.png, blocks/msm_ajax_slider/css_form/repeatable-ft.form.css, blocks/msm_ajax_slider/css_form, blocks/msm_ajax_slider/auto.js, blocks/msm_ajax_slider/config.json, blocks/msm_ajax_slider/controller.php, blocks/msm_ajax_slider/add.php, blocks/msm_ajax_slider, blocks/msm_banner/config.json, blocks/msm_banner/add.php, blocks/msm_banner/controller.php, blocks/msm_banner/db.xml, blocks/msm_banner/composer.php, blocks/msm_banner/edit.php, blocks/msm_banner/icon.png, blocks/msm_banner/view.php, blocks/msm_banner/form.php, blocks/msm_banner, blocks/parallax_content/icon.png, blocks/parallax_content/form.php, blocks/parallax_content/composer.php, blocks/parallax_content/config.json, blocks/parallax_content/controller.php, blocks/parallax_content/add.php, blocks/parallax_content/edit.php, blocks/parallax_content/db.xml, blocks/parallax_content/view.php, blocks/parallax_content, blocks/msm_modal/icon.png, blocks/msm_modal/form.php, blocks/msm_modal/auto.js, blocks/msm_modal/db.xml, blocks/msm_modal/add.php, blocks/msm_modal/edit.php, blocks/msm_modal/controller.php, blocks/msm_modal/config.json, blocks/msm_modal/view.php, blocks/msm_modal/js_form/select2.sortable.js, blocks/msm_modal/js_form, blocks/msm_modal/composer.php, blocks/msm_modal/auto.css, blocks/msm_modal, blocks/page_list/templates/blog_grid/view.php, blocks/page_list/templates/blog_grid, blocks/page_list/templates/blog_list/view.php, blocks/page_list/templates/blog_list, blocks/page_list/templates/blog_side_list/view.php, blocks/page_list/templates/blog_side_list, blocks/page_list/templates/slick_carousel/view.php, blocks/page_list/templates/slick_carousel, blocks/page_list/templates, blocks/page_list, blocks/msm_manual_nav/view.php, blocks/msm_manual_nav/composer.php, blocks/msm_manual_nav/css_form/repeatable-ft.form.css, blocks/msm_manual_nav/css_form, blocks/msm_manual_nav/config.json, blocks/msm_manual_nav/controller.php, blocks/msm_manual_nav/templates/carousel.php, blocks/msm_manual_nav/templates, blocks/msm_manual_nav/add.php, blocks/msm_manual_nav/form.php, blocks/msm_manual_nav/js_form/handlebars-helpers.js, blocks/msm_manual_nav/js_form/handlebars-v4.0.4.js, blocks/msm_manual_nav/js_form, blocks/msm_manual_nav/auto.js, blocks/msm_manual_nav/icon.png, blocks/msm_manual_nav/db.xml, blocks/msm_manual_nav/edit.php, blocks/msm_manual_nav, blocks/page_contents_block/config.json, blocks/page_contents_block/db.xml, blocks/page_contents_block/form.php, blocks/page_contents_block/icon.png, blocks/page_contents_block/view.php, blocks/page_contents_block/add.php, blocks/page_contents_block/edit.php, blocks/page_contents_block/controller.php, blocks/page_contents_block/composer.php, blocks/page_contents_block, blocks/msm_tabs/composer.php, blocks/msm_tabs/config.json, blocks/msm_tabs/css_form/repeatable-ft.form.css, blocks/msm_tabs/css_form, blocks/msm_tabs/view.php, blocks/msm_tabs/auto.js, blocks/msm_tabs/add.php, blocks/msm_tabs/controller.php, blocks/msm_tabs/edit.php, blocks/msm_tabs/icon.png, blocks/msm_tabs/form.php, blocks/msm_tabs/db.xml, blocks/msm_tabs/js_form/handlebars-helpers.js, blocks/msm_tabs/js_form/handlebars-v4.0.4.js, blocks/msm_tabs/js_form, blocks/msm_tabs, blocks/msm_nav/edit.php, blocks/msm_nav/view.php, blocks/msm_nav/add.php, blocks/msm_nav/config.json, blocks/msm_nav/db.xml, blocks/msm_nav/controller.php, blocks/msm_nav/composer.php, blocks/msm_nav/icon.png, blocks/msm_nav/form.php, blocks/msm_nav, blocks/testimonials_with_schema/form.php, blocks/testimonials_with_schema/carousel.js, blocks/testimonials_with_schema/composer.php, blocks/testimonials_with_schema/icon.png, blocks/testimonials_with_schema/js_form/handlebars-helpers.js, blocks/testimonials_with_schema/js_form/handlebars-v4.0.4.js, blocks/testimonials_with_schema/js_form, blocks/testimonials_with_schema/edit.php, blocks/testimonials_with_schema/db.xml, blocks/testimonials_with_schema/css_form/repeatable-ft.form.css, blocks/testimonials_with_schema/css_form, blocks/testimonials_with_schema/view.php, blocks/testimonials_with_schema/controller.php, blocks/testimonials_with_schema/auto.js, blocks/testimonials_with_schema/config.json, blocks/testimonials_with_schema/add.php, blocks/testimonials_with_schema, blocks/share_page/controller.php, blocks/share_page/db.xml, blocks/share_page/edit.php, blocks/share_page/images/ico-share.png, blocks/share_page/images/icons.png, blocks/share_page/images/share-arrow.png, blocks/share_page/images, blocks/share_page/add.php, blocks/share_page/composer.php, blocks/share_page/config.json, blocks/share_page/form.php, blocks/share_page/icon.png, blocks/share_page/view.php, blocks/share_page, themes/website_by_madesimplemedia/default.php, themes/website_by_madesimplemedia/images/banner1.jpg, themes/website_by_madesimplemedia/images/loader.gif, themes/website_by_madesimplemedia/images/loader.svg, themes/website_by_madesimplemedia/images/logo.png, themes/website_by_madesimplemedia/images/pagetypes/four-columns.png, themes/website_by_madesimplemedia/images/pagetypes/full.png, themes/website_by_madesimplemedia/images/pagetypes/left-sidebar.png, themes/website_by_madesimplemedia/images/pagetypes/news-article.png, themes/website_by_madesimplemedia/images/pagetypes/news-page.png, themes/website_by_madesimplemedia/images/pagetypes/right-sidebar.png, themes/website_by_madesimplemedia/images/pagetypes/three-columns.png, themes/website_by_madesimplemedia/images/pagetypes/three-then-two.png, themes/website_by_madesimplemedia/images/pagetypes/two-column.png, themes/website_by_madesimplemedia/images/pagetypes/two-then-three.png, themes/website_by_madesimplemedia/images/pagetypes, themes/website_by_madesimplemedia/images/slide1.jpg, themes/website_by_madesimplemedia/images/msm.png, themes/website_by_madesimplemedia/images, themes/website_by_madesimplemedia/fonts/fontawesome-webfont.eot, themes/website_by_madesimplemedia/fonts/fontawesome-webfont.svg, themes/website_by_madesimplemedia/fonts/fontawesome-webfont.ttf, themes/website_by_madesimplemedia/fonts/fontawesome-webfont.woff, themes/website_by_madesimplemedia/fonts/fontawesome-webfont.woff2, themes/website_by_madesimplemedia/fonts/FontAwesome.otf, themes/website_by_madesimplemedia/fonts/glyphicons-halflings-regular.ttf, themes/website_by_madesimplemedia/fonts/glyphicons-halflings-regular.woff, themes/website_by_madesimplemedia/fonts, themes/website_by_madesimplemedia/left_sidebar.php, themes/website_by_madesimplemedia/thumbnail.png, themes/website_by_madesimplemedia/js/all.js, themes/website_by_madesimplemedia/js/jquery.cookie.min.js, themes/website_by_madesimplemedia/js/jquery.placeholder.min.js, themes/website_by_madesimplemedia/js/modernizr.js, themes/website_by_madesimplemedia/js/respond.min.js, themes/website_by_madesimplemedia/js/selectivizr-min.js, themes/website_by_madesimplemedia/js/site.js, themes/website_by_madesimplemedia/js/slick.min.js, themes/website_by_madesimplemedia/js, themes/website_by_madesimplemedia/description.txt, themes/website_by_madesimplemedia/full.php, themes/website_by_madesimplemedia/home.php, themes/website_by_madesimplemedia/elements/footer.php, themes/website_by_madesimplemedia/elements/footer_bottom.php, themes/website_by_madesimplemedia/elements/header.php, themes/website_by_madesimplemedia/elements/header_top.php, themes/website_by_madesimplemedia/elements, themes/website_by_madesimplemedia/view.php, themes/website_by_madesimplemedia/product.php, themes/website_by_madesimplemedia/css/accordions.less, themes/website_by_madesimplemedia/css/aos.less, themes/website_by_madesimplemedia/css/avatarCreator.less, themes/website_by_madesimplemedia/css/blog_list.less, themes/website_by_madesimplemedia/css/blog_post.less, themes/website_by_madesimplemedia/css/bootstrap.less, themes/website_by_madesimplemedia/css/bootstrap.min.css, themes/website_by_madesimplemedia/css/buttons.less, themes/website_by_madesimplemedia/css/cookie_bar.less, themes/website_by_madesimplemedia/css/donate_box.less, themes/website_by_madesimplemedia/css/edit_mode.less, themes/website_by_madesimplemedia/css/fontawesome.less, themes/website_by_madesimplemedia/css/fontawesome.less4.2, themes/website_by_madesimplemedia/css/footer.less, themes/website_by_madesimplemedia/css/forms.less, themes/website_by_madesimplemedia/css/header.less, themes/website_by_madesimplemedia/css/image_slider.less, themes/website_by_madesimplemedia/css/layout_box.less, themes/website_by_madesimplemedia/css/layout_section_spacing.less, themes/website_by_madesimplemedia/css/logged_in.less, themes/website_by_madesimplemedia/css/mixins.less, themes/website_by_madesimplemedia/css/msm_ajax_image_slider.less, themes/website_by_madesimplemedia/css/msm_banner.less, themes/website_by_madesimplemedia/css/msm_image_with_copy.less, themes/website_by_madesimplemedia/css/msm_manual_nav.less, themes/website_by_madesimplemedia/css/msm_modal.less, themes/website_by_madesimplemedia/css/msm_tabs.less, themes/website_by_madesimplemedia/css/navigation.less, themes/website_by_madesimplemedia/css/navigation_breadcrumbs.less, themes/website_by_madesimplemedia/css/navigation_footer.less, themes/website_by_madesimplemedia/css/navigation_subnav.less, themes/website_by_madesimplemedia/css/overlay.less, themes/website_by_madesimplemedia/css/page_contents.less, themes/website_by_madesimplemedia/css/paging.less, themes/website_by_madesimplemedia/css/parallax_content.less, themes/website_by_madesimplemedia/css/presets/defaults.less, themes/website_by_madesimplemedia/css/presets, themes/website_by_madesimplemedia/css/resets.less, themes/website_by_madesimplemedia/css/safari.less, themes/website_by_madesimplemedia/css/screen.less, themes/website_by_madesimplemedia/css/slick.less, themes/website_by_madesimplemedia/css/social_icons.less, themes/website_by_madesimplemedia/css/store.less, themes/website_by_madesimplemedia/css/store_cart_modal.less, themes/website_by_madesimplemedia/css/store_checkout.less, themes/website_by_madesimplemedia/css/styles.xml, themes/website_by_madesimplemedia/css/tables.less, themes/website_by_madesimplemedia/css/typography.less, themes/website_by_madesimplemedia/css/utilities.less, themes/website_by_madesimplemedia/css/cms.less, themes/website_by_madesimplemedia/css, themes/website_by_madesimplemedia/right_sidebar.php, themes/website_by_madesimplemedia/blog_post.php, themes/website_by_madesimplemedia/page_theme.php, themes/website_by_madesimplemedia

# Concrete Cache Settings
Block Cache - Off
Overrides Cache - Off
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
LiteSpeed

# Server API
litespeed

# PHP Version
8.0.28

# PHP Extensions
bcmath, bz2, calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, i360, iconv, igbinary, imagick, imap, intl, json, libxml, litespeed, mbstring, mcrypt, memcached, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, redis, Reflection, session, shmop, SimpleXML, soap, sockets, sodium, SourceGuardian, SPL, sqlite3, standard, timezonedb, tokenizer, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 120
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 360
max_input_vars - 8000
max_multipart_body_parts - -1
memory_limit - 1024M
post_max_size - 512M
upload_max_filesize - 512M
zend.exception_string_param_max_len - 15
mbstring.regex_retry_limit - 1000000
mbstring.regex_stack_limit - 100000
memcached.sess_lock_max_wait - not set
memcached.sess_lock_wait_max - 150
memcached.sess_server_failure_limit - 0
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
redis.pconnect.connection_limit - 0
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
unserialize_max_depth - 4096
opcache.jit_bisect_limit - 0
opcache.jit_max_exit_counters - 8192
opcache.jit_max_loop_unrolls - 8
opcache.jit_max_polymorphic_calls - 2
opcache.jit_max_recursive_calls - 2
opcache.jit_max_recursive_returns - 2
opcache.jit_max_root_traces - 1024
opcache.jit_max_side_traces - 128
opcache.max_accelerated_files - 7963
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.