Code Monkey home page Code Monkey logo

Comments (3)

neilime avatar neilime commented on June 14, 2024

Hi @bogal

I think that this test case should help you : https://github.com/neilime/twbs-helper-module/blob/master/tests/TestSuite/TwbsHelper/Form/View/Helper/FormTest.php#L32

from twbs-helper-module.

rarog avatar rarog commented on June 14, 2024

I usually use __construct for this. Almost like in this example: https://docs.laminas.dev/laminas-form/quick-start/#factory-backed-form-extension
But I do not bend the constructor and use the same signature. This works perfectly for me:

class MyForm extends Form
{
    /**
     * Constructor
     *
     * @param null|int|string $name Optional name for the element
     * @param array $options Optional options for the element
     */
    public function __construct($name = null, $options = [])
    {
        $options['layout'] = \TwbsHelper\Form\View\Helper\Form::LAYOUT_HORIZONTAL;

        parent::__construct('myForm', $options);

        $this->add([
           'name' => 'name',
            'type'  => Text::class,
            'options' => [
               'label' => 'Your name',
               'label_attributes' => [
                   'column' => 'md-2',
                   'class' => 'col-form-label'
                ],
               'column' => 'md-10'
            ],
            'attributes' => [
                'placeholder' => 'some value',
                'class' => 'form-control'
           ],
        ]);
    }

from twbs-helper-module.

github-actions avatar github-actions commented on June 14, 2024

This issue is stale

from twbs-helper-module.

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.