Jump to content

Recommended Posts

Posted (edited)

Hello,

Since IPS 4.7.6 upgrade, the input type text form field with autocomplete function doesn't work anymore with freeChoice option set to false.

Here is the function that extends formElements in my plugin:

static public function formElements($item = NULL, \IPS\Node\Model $container = NULL) 
{
    [...]
    $wpPostField = new \IPS\Helpers\Form\Text(
        'wp_post', 
        $wpPostFieldValue, 
        false, 
        [
            'autocomplete' => [
                'source' => $wpPostTitles,
                'freeChoice' => false,
                'maxItems' => 1,
                'minItems' => 1,
                'unique' => true,
                'forceLower' => false,
                'prefix' => false,
                'minimized' => false,
                'desc' => \IPS\Settings::i()->lttwpp_wp_post_field_description
            ],
            'placeholder' => \IPS\Settings::i()->lttwpp_wp_post_field_placeholder
        ], 
        function ($value) use ($wpPostTitles) {
            if (!empty($value) && !\in_array($value, $wpPostTitles)) {
                throw new \DomainException('The selected WP post does not exist.');
            }
        }, 
        null, 
        null, 
        'wp_post'
    );

Here is the error:

Quote

TypeError thrown with message "in_array(): Argument #2 ($haystack) must be of type array, null given"

Stacktrace:
#17 TypeError in /var/www/html/web/ips/system/Theme/Theme.php:4628
#16 in_array in /var/www/html/web/ips/system/Theme/Theme.php:4628
#15 IPS\Theme\theme_core_global_forms_autocomplete in /var/www/html/web/ips/system/Theme/Dev/Template.php:171
#14 IPS\Theme\Dev\_Template:__call in /var/www/html/web/ips/system/Theme/Theme.php:4628
#13 IPS\Theme\theme_core_global_forms_text in /var/www/html/web/ips/system/Theme/Dev/Template.php:171
#12 IPS\Theme\Dev\_Template:__call in /var/www/html/web/ips/system/Helpers/Form/Text.php:156
#11 IPS\Helpers\Form\_Text:html in /var/www/html/web/ips/system/Helpers/Form/FormAbstract.php:270
#10 IPS\Helpers\Form\_FormAbstract:rowHtml in /var/www/html/web/ips/system/Helpers/Form/FormAbstract.php:236
#9 IPS\Helpers\Form\_FormAbstract:__toString in /var/www/html/web/ips/system/Theme/Theme.php:4628
#8 IPS\Theme\theme_forums_front_submit_createTopicForm in /var/www/html/web/ips/system/Theme/Dev/Template.php:171
#7 IPS\Theme\Dev\_Template:__call in /var/www/html/web/ips/system/Helpers/Form/Form.php:519
#6 IPS\Helpers\_Form:customTemplate in /var/www/html/web/ips/applications/forums/modules/front/forums/forums.php:653
#5 IPS\forums\modules\front\forums\_forums:add in /var/www/html/web/ips/system/Dispatcher/Controller.php:107
#4 IPS\Dispatcher\_Controller:execute in /var/www/html/web/ips/applications/forums/modules/front/forums/index.php:72
#3 IPS\forums\modules\front\forums\_index:__call in /var/www/html/web/ips/system/Dispatcher/Controller.php:107
#2 IPS\Dispatcher\_Controller:execute in /var/www/html/web/ips/applications/forums/modules/front/forums/index.php:52
#1 IPS\forums\modules\front\forums\_index:execute in /var/www/html/web/ips/system/Dispatcher/Dispatcher.php:153
#0 IPS\_Dispatcher:run in /var/www/html/web/ips/index.php:13

When I set freeChoise parameter to true, it's working but it's not what I want.

Can you help me?

Thanks!

Edited by DreamOn
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...