Giter VIP home page Giter VIP logo

Comments (2)

ifox avatar ifox commented on June 10, 2024

Yes it can, in the case where $modules is an array that contains exactly one element, but that element is not at the index 0. This can happen if the array uses non-sequential or non-numeric keys.

Non-sequential keys: If the array's keys are not sequential, and the starting key is not 0, then count($modules) could return 1 (indicating that there is one element in the array), but $modules[0] would not be set because the key 0 does not exist in the array.

Associative array with a single element: If $modules is an associative array (where keys are strings instead of integers), and it contains just one element with a key other than 0, count($modules) would be 1, but isset($modules[0]) would evaluate to false since there's no element with the key 0.

This condition is to account for someone passing something like this: ['posts' => Post::class].

from twill.

iedex avatar iedex commented on June 10, 2024

Ah, got it. I was looking for a method to use only one module, because moduleName doesn't work in FormBuilder, and when using modules(['module_name']) the browser has that selector for the single module.
Tried now and it works as expected with ->modules(['name' => 'module_name']).
Thanks a lot!

from twill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.