Problem/Motivation

PHP notice thrown from tac_lite_create_form_alter:

Notice: Undefined index: #type in tac_lite_create_form_alter() (line 72 of my_site\sites\all\modules\tac_lite\tac_lite_create.module)

Steps to reproduce

  1. Add a access_control
  2. taxonomy, with at least one term

  3. Set this term as the default value for an entity reference field on the article node type. Don't customize any form display for the field
  4. Set this term as a tac lite scheme
  5. Log in as a non-admin user
  6. Browse to add a node, see the php notice.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#8 2190277-08.patch1.91 KBjhedstrom
#2 tac_lite_debug.diff763 bytesDave Cohen

Comments

Mirkozzo’s picture

Issue summary: View changes
Dave Cohen’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new763 bytes

Can you apply this patch which will print some debug info? I want to know what kind of field you have enabled.

Mirkozzo’s picture

Tnx for debug script.

Debug report:

The mystery field that has no type is field_rso_soluzione.

Array
(
    [#type] => container
    [#attributes] => Array
        (
            [class] => Array
                (
                    [0] => field-type-taxonomy-term-reference
                    [1] => field-name-field-rso-soluzione
                    [2] => field-widget-taxonomy-shs
                )

        )

    [#weight] => 0
    [#tree] => 1
    [#language] => und
    [und] => Array
        (
            [0] => Array
                (
                    [tid] => Array
                        (
                            [#entity_type] => node
                            [#entity] => stdClass Object
                                (
                                    [uid] => 26
                                    [name] => my_user_name
                                    [type] => tac_lite
                                    [language] => und
                                    [title] => 
                                    [status] => 1
                                    [promote] => 0
                                    [sticky] => 0
                                    [created] => 1391763113
                                    [revision] => 
                                    [comment] => 2
                                    [menu] => Array
                                        (
                                            [link_title] => 
                                            [mlid] => 0
                                            [plid] => 0
                                            [menu_name] => main-menu
                                            [weight] => 0
                                            [options] => Array
                                                (
                                                )

                                            [module] => menu
                                            [expanded] => 0
                                            [hidden] => 0
                                            [has_children] => 0
                                            [customized] => 0
                                            [parent_depth_limit] => 8
                                        )

                                )

                            [#bundle] => tac_lite
                            [#field_name] => field_rso_soluzione
                            [#language] => und
                            [#field_parents] => Array
                                (
                                )

                            [#columns] => Array
                                (
                                    [0] => tid
                                )

                            [#title] => Soluzione
                            [#description] => 
                            [#required] => 
                            [#delta] => 0
                            [#weight] => 0
                            [#type] => textfield
                            [#default_value] => 
                            [#attributes] => Array
                                (
                                    [class] => Array
                                        (
                                            [0] => shs-enabled
                                        )

                                )

                            [#maxlength] => 
                            [#element_validate] => Array
                                (
                                    [0] => shs_field_widget_validate
                                )

                            [#after_build] => Array
                                (
                                    [0] => shs_field_widget_afterbuild
                                )

                            [#shs_settings] => Array
                                (
                                    [node_count] => 0
                                    [create_new_terms] => 
                                    [create_new_levels] => 0
                                    [force_deepest] => 0
                                    [required] => 
                                )

                            [#shs_vocabulary] => stdClass Object
                                (
                                    [vid] => 4
                                    [name] => RSO - Soluzioni
                                    [machine_name] => rso_soluzioni
                                    [description] => 
                                    [hierarchy] => 0
                                    [module] => taxonomy
                                    [weight] => -7
                                )

                        )

                )

            [#theme] => field_multiple_value_form
            [#field_name] => field_rso_soluzione
            [#cardinality] => 1
            [#title] => Soluzione
            [#required] => 0
            [#description] => 
            [#prefix] => 

            [#suffix] => 

            [#max_delta] => 0
            [#after_build] => Array
                (
                    [0] => field_form_element_after_build
                )

            [#language] => und
            [#field_parents] => Array
                (
                )

        )

    [#access] => 1
)

The problem is module "shs"(Simple hierarchical select),
if i don't use shs's widget there are no errors, but i need it

If i select shs's widget, it display 2 errors per field. In my fist post i used 2 taxonomy field with shs's widget -> 4 error message

Mirkozzo’s picture

Is it possible to fix?

Mirkozzo’s picture

news?

Mirkozzo’s picture

news?

jhedstrom’s picture

Version: 7.x-1.2 » 8.x-1.x-dev
Assigned: Mirkozzo » jhedstrom
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Seeing this in D8 still. Also running with SHS, so that module seems to still be altering the form/widget in such a way this module isn't expecting.

jhedstrom’s picture

Assigned: jhedstrom » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.91 KB

This actually wasn't caused by SHS, but was reproducible with just tac_lite.

mroycroft’s picture

I've reviewed the code changes, patch looks good. I haven't had time to manually test this yet.

  • mukila committed f6ab742 on 8.x-1.x
    Issue #2190277 by jhedstrom, Dave Cohen: Undefined index:...

mukila credited mukila.

mukila’s picture

Status: Needs review » Fixed

Updated the changes in 8.x-1.3 release

lpsolit’s picture

@mukila: is this the right commit? It has nothing to do with the patch proposed in comment 8. Or was the patch in comment 8 incorrect and you fixed the bug in a different way?

Also, about your commit, this change cannot be right:

- if ($form[$field_name]['widget']['#type'] != 'select' && $form[$field_name]['widget']['#type'] != 'radios') {
- continue;
- }
+ if (isset($form[$field_name]['widget']['#type']) && ($form[$field_name]['widget']['#type'] == 'select' || $form[$field_name]['widget']['#type'] != 'radios' || $form[$field_name]['widget']['#type'] != 'checkboxes')) {

In the initial code, the code stopped ("continue") if the type was neither 'select' nor 'radios'. Said differently, the code was going on if it was either 'select' or 'radios'. In your commit, your code *always* goes on, because "either not radios or not 'checkboxes'" will always evaluate to true. What you want is == instead of !=.

mukila’s picture

Thanks a lot LpSolit for your comments. The patch in comment in 8 is incorrect(After applying the patch it throws Notice: Undefined index: #options in tac_lite_create_form_alter() ), so I tried to fix it in different way(Support only for select box, checkboxes, radios widget). But there is some bug in the commit. You're correct, we need to replace != with ==

  • mukila committed a935205 on 8.x-1.x
    Issue #2190277 by jhedstrom, mukila, LpSolit: Undefined index:...
lpsolit’s picture

Thanks for the new commit. It now looks good (and is much cleaner). :)

I guess you will release 8.x-1.4 very soon as the release yesterday is bogus?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.