English 中文(简体)
在第7号博士中,为什么没有自动填写这一表格要素清单?
原标题:In Drupal 7, why is autocomplete not attaching to this list of form elements?

我愿附上第7博士的具体田地清单。 这些田地有<条码>FIELD_CARDINALITY_UNLIMITED,因此,任何地方都可以从1到1。 I m 采用以下代码:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if (array_key_exists( mymodule , $form)) {

        $indices = array_filter(
            array_keys($form[ mymodule ][ und ]), 
            function($item) {
                return is_numeric($item);
            }
        );

        foreach($indices as $index) {
            $form[ mymodule ][ und ][$index][ value ][ #autocomplete_path ] =  api/node/title ;
        }
    }
}

...however, my autocomplete behavior is not being attached. I ve used the exact same code in a similar situation - the only difference is that I was adding the autocomplete to a field that had a cardinality of 1 rather than unlimited. That doesn t seem like it should change anything. I ve verified that the autocomplete is attaching by doing a debug($form[ mymodule ]) after the assignment statement, and it is definitely there. I have also debugged the exact array path I am trying to get in each iteration of the foreach loop, and it is definitely the correct form value.

EDIT:是否可以将这一问题放在一个以上模块上,使用<代码>hook_form_alter(? I m以同样的形式,以不同的模块进行与上文(但在单一领域)相同的操作。

EDIT2:我已注意到,如果我在每个通道上作假发言,我就看到汽车残值按每艘轮胎的适当价值计算。 如果我把辩论发言放在旁听器之外,汽车路就不再固定。 不管怎么说,无论是在循环过程中,还是在循环之后,都看着我的变化正在遭到破坏? 我通过将<代码>(index_0)假设为“0”,并撰写硬编码说明,附上自动填写,从而使汽车能够正确工作。 很显然,我看到以下一点:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if (array_key_exists( mymodule , $form)) {

        $indices = array_filter(
            array_keys($form[ mymodule ][ und ]), 
            function($item) {
                return is_numeric($item);
            }
        );

        foreach($indices as $index) {
            $form[ mymodule ][ und ][$index][ value ][ #autocomplete_path ] =  api/node/title ;
            // Debug statements here show that the value  #autocomplete_path  is set properly
            debug($form)[ mymodule ][ und ][$index][ value ]);
        }

        // Now, the  #autocomplete_path  key does not exist
        debug($form)[ mymodule ][ und ][0][ value ]);

        // This will make autocomplete attach correctly
        $form[ mymodule ][ und ][0][ value ][ #autocomplete_path ] =  api/node/title ;
    }
}
最佳回答

I resolved the problem by manually enumerating my indices rather than programmatically doing so, e.g. $form[ mymodule ][ und ][0]... - this appears to be a PHP issue related to scoping of variables in foreach rather than a Drupal problem.

问题回答

页: 1

如果你重新界定实地(和植被),那么你就应当仅仅在你的模块实施过程中添加汽车内容:。 而不是改变形式。

http://api.drupal.org/api/drupal/modules-field-field.api.php/Function/hook_field_widget_form_/7"rel=“nofollow”>hook_field_widget_form_alter_

为此:

1) change [ mymodule ][ und ][$index][ value ] in your code to the id of your text form input example

$form[ search_form_block ]
[ #autocomplete_path ]= yourcall_back_function_which_returns_data ;

我认为,错误是你试图取代实地的价值,但必须改变这种方式的价值。 在这种情况下,投入领域。

(2) 还确保使用x debug的复印件/发价/发价背书。

让我知道这是否奏效。

Cheers, vishal





相关问题
Drupal Multi-language: Simple strings not translated

I m adding additional languages to a Drupal site that I m building. Getting the translation of content working is fairly easy using the Internationalisation module. Yet, simple things such as date ...

Setting up a WYSIWYG editor for Drupal site users [closed]

Looking through the Drupal contrib modules, and after a few Google searches, it becomes evident that there are any number of choices and combos available to set up a WYSIWYG editor in Drupal. I m ...

Change size of user/password login box

I don t know how to change the size of the login username/password boxes on the drupal site that I m trying to build. I m stumbling through the theming, and don t know where to find the file that ...

How does Drupal provide an edit/review/publish model?

How does Drupal support a means to update and review a website before it is published? Does it only allow you to preview a page at a time before you publish it or is there a way to create a site ...

Term for rotating header

I m looking for terminology that describes this behavior: The header of a web-page contains a different image every time you visit it. Update: It is not an advertisement, but images related to the ...

Has anyone checked out Drupal 7? [closed]

Has anyone checked out a copy of Drupal 7 yet? What do people think? I m pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure. Do ...

热门标签