Code Monkey home page Code Monkey logo

twbs-helper-module's People

Contributors

becoded avatar dependabot-preview[bot] avatar dependabot[bot] avatar driehle avatar froschdesign avatar lee-hanson avatar matusmark avatar neilime avatar rarog avatar rolandoisidoro avatar saeven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

twbs-helper-module's Issues

Support for Bootstrap 5

Hi, Emilien!

The Bootstrap 5 released a few days ago. Can you have a plans to update this module to support this version in near future?

After 3.2.0 I'm unable to group buttons from the form the form helper.

Before just by calling $this->form($myForm) from my view I was able to render button groups just via options inside the \Laminas\Form\Form, with the change the call of group buttons logic was replaced by form rows. As far as I see there is no possibility to enforce button grouping from the form array notation and I would have to do manual assembling of the form.

Can the old behaviour be restored in parallel to the form row implementation?

Label of radios rendered underneath the elements in Version 4.1.1

Same as in issue #294 but for version 4.1.1

Describe the bug
The label for a radio-list is rendered underneath the elements instead of above.

echo $this->formRow(
    $factory->create(
        [
            'name'       => 'flexRadioDefault',
            'type'       => 'radio',
            'options'    => [
               'label' => Choose from the list below
                'form_group'    => false,
                'value_options' => [
                    [
                        'label'      => 'Default radio',
                        'value'      => 'option1',
                        'attributes' => ['id' => 'flexRadioDefault1'],
                    ],
                    [
                        'label'      => 'Default checked radio',
                        'value'      => 'option2',
                        'attributes' => ['id' => 'flexRadioDefault2'],
                    ],
                ],
            ],
            'attributes' => [    'value' => 'option2'    ],
        ]
    )
);

Actual behavior

o Default radio
o Default checked radio
Choose from the list below

Expected behavior

Choose from the list below
o Default radio
o Default checked radio

Invalid rendering of form-append/prepend icons

I found an error of rendering form-append/prepend icons in version 2.0.

This happens because function (FormButton.php, line 351):
$sIconContent = $this->htmlElement('i', ['class' => $aIconOptions['class']]);
returns unclosed <i> tag and it brokes all markup.

Trait HtmlTrait.php returns unclosed tag because it has empty content:

$sElementContent = '<' . $sTag . $sAttributes;
if ($sContent === null) {
    $sElementContent .= $this->getView()->plugin('HtmlTag')->getClosingBracket();
    return $sElementContent;
}

Installing via composer installs zend components, not laminas

As the title suggests, when installed via composer with the command:
composer require neilime/zf-twbs-helper-module
...it installs a lot of zend components, not laminas components.

Composer output from above command:

Using version ^2.1 for neilime/zf-twbs-helper-module
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals

  • Installing zendframework/zend-progressbar (2.7.0): Downloading (100%)
  • Installing zendframework/zend-paginator (2.8.2): Downloading (100%)

Please select which config file you wish to inject 'Zend\Paginator' into:
[0] Do not inject
[1] config/modules.config.php
[2] config/development.config.php.dist
Make your selection (default is 1):

Horizontal Layout class not applied and div missing

Hi Again.

Horizontal form layout is still not working as expected (related to previous issue #440 ).

When you set a form to horizontal layout it should apply a class to the label and wrap the input in a div. The old zf2 Twb helper used to do this.

eg,
expected

<div class="mb-3 row">
    <label class="form-label col-sm-2 " for="title">Title</label>
    <div class="col-sm-10">
        <input class="form-control" name="title" type="text" value="">
    </div>
</div>

got

<div class="mb-3 row">
    <label class="form-label" for="title">Title</label>
    <input class="form-control" name="title" type="text" value="">
</div>

This module stops to work today after latest laminas/laminas-servicemanager update to version 3.6.0

This module stops to work today after latest laminas/laminas-servicemanager update to version 3.6.0+. All form elements renders with default Laminas view helpers instead of twbs helpers.

To Reproduce
Steps to reproduce the behavior:

  1. Update laminas/laminas-servicemanager to latest version (3.6.1)
  2. Run script that uses twbs form helpers

Expected behavior
Form elements renders with twbs view helpers

The FormElement view helper doesn't add is-invalid class

The FormElement view helper doesn't add is-invalid class if called alone. That makes the error messages to be hidden. To get is-invalid class we are obliged to use the formRowElement.

Example here with an invalid form element:

echo $this->formElement($element);
echo $this->formElementErrors($element)

Generated HTML:

<div class="col controls">
        <input class="form-control" id="nom" name="nom" type="text" value="">
        <div class="invalid-feedback">Champ obligatoire</div>
</div>

Expected behavior

<div class="col controls">
        <input class="form-control is-invalid" id="nom" name="nom" type="text" value="">
        <div class="invalid-feedback">Champ obligatoire</div>
</div>

As you can see here, the HTML error is generated but hidden due to the missing is-invalid class on the element:
image

If I add manually the is-invalid class, it works:
image

Version 36.3 released in Packagist

Describe the bug
It seems like there happened a mistake in the release process and a version 36.3 has been release by accident. I was made aware of that as Dependabot notified me with a PR. 36.3 was released earlier than 3.6.8 (most likely as a typo of 3.6.3).

To Reproduce
See
https://packagist.org/packages/neilime/twbs-helper-module

Expected behavior
From my point of view you could simply delete the release on Packagist. However, that will cause issues for people who may have already updated. The other solution would be to continue with 37.0.0 as the next version.

formCollection truncate content

Hi
Describe the bug
When a call is made to formCollection and $wrap is set to true, some elements are removed.

To Reproduce
Steps to reproduce the behavior:
Create a form like this :

<?php

namespace Administration\Form;

use DoctrineORMModule\Form\Annotation\AnnotationBuilder as DoctrineBuilder;
use Zend\Form\Form;
use Doctrine\Common\Persistence\ObjectManager;
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator;
use Zend\Form\Annotation\AnnotationBuilder;
use Zend\Form\FormElementManager;
use Administration\Entity\Production;
use ZN\Form\Factory as ZNFormFactory;

class ProductionFormFactory extends Form
{
    /**
     * Constructor
     */
    public function __construct(ObjectManager $objectManager,FormElementManager $formmanager)
    {
        // we want to ignore the name passed
        parent::__construct('entity-create-form');
        $this->setAttribute('method', 'post');
       // $this->setOption("column",8);
          //  ->setHydrator(new DoctrineHydrator($objectManager));
        $builder = new DoctrineBuilder($objectManager);
        $builder->setFormFactory(new ZNFormFactory($formmanager));
        $entity = new Production();
        //Add the fieldset, and set it as the base fieldset
        $fieldset = $builder->createForm($entity);
        $fieldset->setHydrator(new DoctrineHydrator($objectManager, 'Administration\\Entity\\Production'));
        $fieldset->setName("Production");
        $fieldset->setUseAsBaseFieldset(true);

        $this->add($fieldset);

        $this->add(array(
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf'
        ));

        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                'type' => 'submit',
                'value' => 'Save'
            )
        ));
    }
}

Then call the view helper <?php echo $this->formCollection($this->form,true); ?>

Expected behavior
Precedent behaviour rendered this :

<fieldset class="needs-validation"><fieldset class="">
    <div class="form-group">
        <label for="Production&#x5B;idproduction&#x5D;">ID</label>
        <input type="number" name="Production&#x5B;idproduction&#x5D;" readonly="readonly" class="form-control" value="23">
    </div><div class="form-group&#x20;required">
        <label for="Production&#x5B;name&#x5D;">Nom</label>
        <input type="text" name="Production&#x5B;name&#x5D;" class="form-control" value="uyi">
    </div><div class="form-group&#x20;required">
        <label for="Production&#x5B;alias&#x5D;">Alias</label>
        <input type="text" name="Production&#x5B;alias&#x5D;" class="form-control&#x20;required" required="required" value="ui">
        <small class="form-text&#x20;text-muted">No special <code>characters</code></small>
    </div><div class="form-group&#x20;required">
        <label for="Production&#x5B;key&#x5D;">Clé</label>
        <input type="text" name="Production&#x5B;key&#x5D;" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
    </div><div class="form-group">
        <label for="Production&#x5B;dateOfCreation&#x5D;">Date de création</label>
        <input type="date" name="Production&#x5B;dateOfCreation&#x5D;" class="form-control" value="">
    </div><div class="form-group">
        <label for="Production&#x5B;dateOfClosure&#x5D;">Closure date</label>
        <input type="date" name="Production&#x5B;dateOfClosure&#x5D;" class="form-control" value="">
    </div><div class="form-group">
        <label for="Production&#x5B;pathdownload&#x5D;">Path download</label>
        <input type="text" name="Production&#x5B;pathdownload&#x5D;" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
    </div><div class="form-group">
        <label for="Production&#x5B;pathpictures&#x5D;">Path pictures</label>
        <input type="text" name="Production&#x5B;pathpictures&#x5D;" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
    </div><div class="form-group">
        <label for="Production&#x5B;pathcomponent&#x5D;">Path component</label>
        <input type="text" name="Production&#x5B;pathcomponent&#x5D;" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
    </div><div class="form-group">
        <label for="Production&#x5B;depositdirectory&#x5D;">Deposit directory</label>
        <input type="text" name="Production&#x5B;depositdirectory&#x5D;" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
    </div><div class="form-group">
        <label for="Production&#x5B;streamdirectory&#x5D;">Stream directory</label>
        <input type="text" name="Production&#x5B;streamdirectory&#x5D;" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
    </div><div class="form-group">
        <label for="Production&#x5B;menu&#x5D;">Menu</label>
        <input type="number" name="Production&#x5B;menu&#x5D;" class="form-control" value="0">
    </div><div class="form-group">
        <label for="Production&#x5B;streamercode&#x5D;">Streamer</label>
        <input type="number" name="Production&#x5B;streamercode&#x5D;" class="form-control" value="0">
    </div><div class="form-group">
        <label for="Production&#x5B;idservice&#x5D;">Service</label>
        <textarea name="Production&#x5B;idservice&#x5D;" class="form-control"></textarea>
    </div><div class="form-group">
        <label for="Production&#x5B;notes&#x5D;">Notes</label>
        <textarea name="Production&#x5B;notes&#x5D;" class="form-control"></textarea>
    </div><div class="form-group">
        <label for="Production&#x5B;picture&#x5D;">Picture</label>
        <div class="input-group">
            <input name="Production&#x5B;picture&#x5D;" class="form-control" type="text" value="">
            <div class="input-group-append">
                <button type="button" name="button" class="btn&#x20;btn-secondary&#x20;filemanager" value="">choose</button>
            </div>
        </div>
    </div><div class="form-group">
        <label for="Production&#x5B;options&#x5D;">Options</label>
        <input name="Production&#x5B;options&#x5D;" class="form-control" type="text" value="">
    </div><div class="form-group">
        <label for="Production&#x5B;idorganization&#x5D;">Organization</label>
        <select name="Production&#x5B;idorganization&#x5D;" class="form-control">
            <option value="1" selected="selected">hicones</option>
            <option value="14">Quadrille</option>
        </select>
    </div><div class="form-group">
        <label for="Production&#x5B;idgroup&#x5D;">Fields group</label>
        <select name="Production&#x5B;idgroup&#x5D;" class="form-control"><option value="1" selected="selected">default</option></select>
    </div><div class="form-group">
        <label for="Production&#x5B;idpublication&#x5D;">Publication</label>
        <select name="Production&#x5B;idpublication&#x5D;&#x5B;&#x5D;" multiple="multiple" class="form-control"></select>
    </div><div class="form-group">
        <div class="form-check">
            <input type="hidden" name="Production&#x5B;isdeleted&#x5D;" value="0"><input type="checkbox" name="Production&#x5B;isdeleted&#x5D;" class="form-check-input" id="chkIsDeleted" value="1" checked="checked">
            <label class="form-check-label" for="chkIsDeleted">Supprimé</label>
        </div>
    </div>
</fieldset><input type="hidden" name="csrf" value="1fed9e380b8d3bbf2d315bdb795e49e2-207e2e3603b273451dc2116208aeb643"><div class="form-group">
    <button name="submit" type="submit" class="btn&#x20;btn-secondary" value="Save">Sauvegarder</button>
</div></fieldset>

Today content is truncated by theses lines in FormCollection :

 if (!preg_match('/(<fieldset[^>]*>)([\s\S]*)(<\/fieldset[^>]*>)/imU', $sMarkup, $aMatches)) {
            return $sMarkup;
        }

        $sMarkup = $aMatches[2];

And the result is

                        <fieldset class="needs-validation">
    <fieldset class="">
        <div class="form-group">
            <label for="Production[idproduction]">ID</label>
            <input type="number" name="Production[idproduction]" readonly="readonly" class="form-control" value="23">
        </div><div class="form-group required">
            <label for="Production[name]">Nom</label>
            <input type="text" name="Production[name]" class="form-control" value="uyi">
        </div><div class="form-group required">
            <label for="Production[alias]">Alias</label>
            <input type="text" name="Production[alias]" class="form-control required" required="required" value="ui">
            <small class="form-text text-muted">No special <code>characters</code></small>
        </div><div class="form-group required">
            <label for="Production[key]">Clé</label>
            <input type="text" name="Production[key]" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
        </div><div class="form-group">
            <label for="Production[dateOfCreation]">Date de création</label>
            <input type="date" name="Production[dateOfCreation]" class="form-control" value="">
        </div><div class="form-group">
            <label for="Production[dateOfClosure]">Closure date</label>
            <input type="date" name="Production[dateOfClosure]" class="form-control" value="">
        </div><div class="form-group">
            <label for="Production[pathdownload]">Path download</label>
            <input type="text" name="Production[pathdownload]" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
        </div><div class="form-group">
            <label for="Production[pathpictures]">Path pictures</label>
            <input type="text" name="Production[pathpictures]" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
        </div><div class="form-group">
            <label for="Production[pathcomponent]">Path component</label>
            <input type="text" name="Production[pathcomponent]" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
        </div><div class="form-group">
            <label for="Production[depositdirectory]">Deposit directory</label>
            <input type="text" name="Production[depositdirectory]" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
        </div><div class="form-group">
            <label for="Production[streamdirectory]">Stream directory</label>
            <input type="text" name="Production[streamdirectory]" required="required" class="form-control" value="9a00ad36-09be-9ff1-0d9e-c45a84fb1974">
        </div><div class="form-group">
            <label for="Production[menu]">Menu</label>
            <input type="number" name="Production[menu]" class="form-control" value="0">
        </div><div class="form-group">
            <label for="Production[streamercode]">Streamer</label>
            <input type="number" name="Production[streamercode]" class="form-control" value="0">
        </div><div class="form-group">
            <label for="Production[idservice]">Service</label>
            <textarea name="Production[idservice]" class="form-control"></textarea>
        </div><div class="form-group">
            <label for="Production[notes]">Notes</label>
            <textarea name="Production[notes]" class="form-control"></textarea>
        </div><div class="form-group">
            <label for="Production[picture]">Picture</label>
            <div class="input-group">
                <input name="Production[picture]" class="form-control" type="text" value="">
                <div class="input-group-append">
                    <button type="button" name="button" class="btn btn-secondary filemanager" value="">choose</button>
                </div>
            </div>
        </div><div class="form-group">
            <label for="Production[options]">Options</label>
            <input name="Production[options]" class="form-control" type="text" value="">
        </div><div class="form-group">
            <label for="Production[idorganization]">Organization</label>
            <select name="Production[idorganization]" class="form-control">
                <option value="1" selected="selected">hicones</option>
                <option value="14">Quadrille</option>
            </select>
        </div><div class="form-group">
            <label for="Production[idgroup]">Fields group</label>
            <select name="Production[idgroup]" class="form-control"><option value="1" selected="selected">default</option></select>
        </div><div class="form-group">
            <label for="Production[idpublication]">Publication</label>
            <select name="Production[idpublication][]" multiple="multiple" class="form-control"></select>
        </div><div class="form-group">
            <div class="form-check">
                <input type="hidden" name="Production[isdeleted]" value="0"><input type="checkbox" name="Production[isdeleted]" class="form-check-input" id="chkIsDeleted" value="1" checked="checked">
                <label class="form-check-label" for="chkIsDeleted">Supprimé</label>
            </div>
        </div>
    
</fieldset>                    </fieldset>

I Have to call formCollection and set $wrap to false, in order to keep all my content, but I have no more fieldset.

Many Thanks for this fantastic library :)

How to add a horizontal form setting when creating a form as a factory from a class

I have read the docs about creating a horizontal form.

But when created from a class-based form factory:

class MyForm extends Form
{
    public function init()
    {
        parent::init();
        $this->setName('myForm');
        $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'
           ],
        ]);
    }
}

...where do i add it? I have tried adding (in the MyForm::init method):
$this->setOptions(['layout', TwbsFormHelper::LAYOUT_HORIZONTAL]);
...but it made no difference.
Rendered in my view as <?php echo $this->form($this->myForm); ?>

File upload seems to pass an array to escape helper

Describe the bug

Using a file upload, I get the following error when validation fails and the form is supposed to be rendered:

Laminas\View\Exception\InvalidArgumentException

File:

    APP_PATH\vendor\laminas\laminas-view\src\Helper\Escaper\AbstractHelper.php:55

Message:

    Array provided to Escape helper, but flags do not allow recursion

Stack trace:

    #0 APP_PATH\vendor\laminas\laminas-form\src\View\Helper\AbstractHelper.php(271): Laminas\View\Helper\Escaper\AbstractHelper->__invoke(Array)
    #1 APP_PATH\vendor\laminas\laminas-form\src\View\Helper\FormInput.php(134): Laminas\Form\View\Helper\AbstractHelper->createAttributesString(Array)
    #2 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\FormFile.php(22): Laminas\Form\View\Helper\FormInput->render(Object(Laminas\Form\Element\File))
    #3 APP_PATH\vendor\laminas\laminas-form\src\View\Helper\FormInput.php(103): TwbsHelper\Form\View\Helper\FormFile->render(Object(Laminas\Form\Element\File))
    #4 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\FormElement.php(100): Laminas\Form\View\Helper\FormInput->__invoke(Object(Laminas\Form\Element\File))
    #5 APP_PATH\vendor\laminas\laminas-form\src\View\Helper\FormElement.php(207): TwbsHelper\Form\View\Helper\FormElement->renderHelper('formfile', Object(Laminas\Form\Element\File))
    #6 APP_PATH\vendor\laminas\laminas-form\src\View\Helper\FormElement.php(116): Laminas\Form\View\Helper\FormElement->renderType(Object(Laminas\Form\Element\File))
    #7 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\FormElement.php(71): Laminas\Form\View\Helper\FormElement->render(Object(Laminas\Form\Element\File))
    #8 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\FormRow.php(194): TwbsHelper\Form\View\Helper\FormElement->render(Object(Laminas\Form\Element\File))
    #9 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\FormRow.php(91): TwbsHelper\Form\View\Helper\FormRow->renderElement(Object(Laminas\Form\Element\File), 'prepend')
    #10 APP_PATH\vendor\laminas\laminas-form\src\View\Helper\FormRow.php(116): TwbsHelper\Form\View\Helper\FormRow->render(Object(Laminas\Form\Element\File), 'prepend')
    #11 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\Form.php(152): Laminas\Form\View\Helper\FormRow->__invoke(Object(Laminas\Form\Element\File))
    #12 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\Form.php(77): TwbsHelper\Form\View\Helper\Form->renderElements(Object(Application\Form\EditEmployeeContract))
    #13 APP_PATH\vendor\neilime\twbs-helper-module\src\TwbsHelper\Form\View\Helper\Form.php(47): TwbsHelper\Form\View\Helper\Form->render(Object(Application\Form\EditEmployeeContract))
    #14 [internal function]: TwbsHelper\Form\View\Helper\Form->__invoke(Object(Application\Form\EditEmployeeContract), NULL)
    #15 APP_PATH\vendor\laminas\laminas-view\src\Renderer\PhpRenderer.php(396): call_user_func_array(Object(TwbsHelper\Form\View\Helper\Form), Array)
    #16 APP_PATH\module\Application\view\application\employee-contract\create.phtml(6): Laminas\View\Renderer\PhpRenderer->__call('form', Array)
    #17 APP_PATH\vendor\laminas\laminas-view\src\Renderer\PhpRenderer.php(505): include('C:\\Users\\Dennis...')
    #18 APP_PATH\vendor\laminas\laminas-view\src\View.php(206): Laminas\View\Renderer\PhpRenderer->render(NULL)
    #19 APP_PATH\vendor\laminas\laminas-view\src\View.php(235): Laminas\View\View->render(Object(Laminas\View\Model\ViewModel))
    #20 APP_PATH\vendor\laminas\laminas-view\src\View.php(199): Laminas\View\View->renderChildren(Object(Laminas\View\Model\ViewModel))
    #21 APP_PATH\vendor\laminas\laminas-mvc\src\View\Http\DefaultRenderingStrategy.php(104): Laminas\View\View->render(Object(Laminas\View\Model\ViewModel))
    #22 APP_PATH\vendor\laminas\laminas-eventmanager\src\EventManager.php(321): Laminas\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Laminas\Mvc\MvcEvent))
    #23 APP_PATH\vendor\laminas\laminas-eventmanager\src\EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent))
    #24 APP_PATH\vendor\laminas\laminas-mvc\src\Application.php(366): Laminas\EventManager\EventManager->triggerEvent(Object(Laminas\Mvc\MvcEvent))
    #25 APP_PATH\vendor\laminas\laminas-mvc\src\Application.php(347): Laminas\Mvc\Application->completeRequest(Object(Laminas\Mvc\MvcEvent))
    #26 APP_PATH\public\index.php(37): Laminas\Mvc\Application->run()
    #27 {main}

The following attributes are trying to be escaped. The attribute value causes the issue here:

array(4) {
  ["type"]=>
  string(4) "file"
  ["name"]=>
  string(4) "file"
  ["class"]=>
  string(17) "form-control-file"
  ["value"]=>
  array(5) {
    ["name"]=>
    string(24) "Guide-for-Presenters.pdf"
    ["type"]=>
    string(15) "application/pdf"
    ["tmp_name"]=>
    string(46) "C:\Users\Dennis\AppData\Local\Temp\php13AD.tmp"
    ["error"]=>
    int(0)
    ["size"]=>
    int(1104622)
  }
}

Steps to reproduce

A simple form with a file element and the following code in the controller:

        if ($request->isPost()) {
            $post = array_merge_recursive(
                $request->getPost()->toArray(),
                $request->getFiles()->toArray()
            );
            $form->setData($post);

            if ($form->isValid()) {
                 ....
            }
        }

View script:

<?php
echo $this->form($this->form, null);
?>

Suggested solution

I think the class TwbsHelper\Form\View\Helper\FormFile should not extend from \Laminas\Form\View\Helper\FormInput but from \Laminas\Form\View\Helper\FormFile. If I change this manually, everything works again.

how do i put a class in the parent div of a radio button?

Today it is like this.

<div class="col-auto">
            <div class="form-check form-check-inline">
                <input class="form-check-input" name="radio1" required="" type="radio" value="1">
                <label>Label 1</label>
            </div>
            <div class="form-check form-check-inline">
                <input class="form-check-input" name="radio2 required="" type="radio" value="2">
                <label>Label 1</label>
            </div>
 </div>

I want to leave it this way, just adding a class in the parent div

<div class="col-auto MY CLASS HERE">
            <div class="form-check form-check-inline">
                <input class="form-check-input" name="radio1" required="" type="radio" value="1">
                <label>Label 1</label>
            </div>
            <div class="form-check form-check-inline">
                <input class="form-check-input" name="radio2 required="" type="radio" value="2">
                <label>Label 1</label>
            </div>
 </div>

Indentation breaks textarea content line-breaks (new lines) on htmlRender

Describe the bug

The "addProperIndentation" method in the HtmlTrait also idents the content of textareas (between element open and close tags). https://github.com/neilime/twbs-helper-module/blob/f02f14ebe529c8d0cf24c6b35f07a65dd7299903/src/TwbsHelper/View/Helper/HtmlTrait.php#L43

Therefore all new lines ("\n") will on render change the original content of the element as you can see on the example screenshots.

Expected behavior
The content of <textarea></textarea> shall not be touched nor automatically idented

Screenshots
View:
image
In source code:
image

Additional context
I cannot find an easy way to fix this behavior but we need to find a quick fix by NOT try to ident in the case of a textarea. I'm not sure if there are even other cases where this behavior is not wanted.

Missing form view helper

It would be really awesome if you could add all form view helper or at least "the" form view helper.

Additional class for column

Hi,

I think it would be useful to be able to add additional classes to form column. By example to add some offset class or similar.

Plus, some components (checkboxes by example) are not aligning properly so sometime I add to column: d-flex align-items-center

Ignore dev file for dist package

Is your feature request related to a problem? Please describe.

Ignore all non needed files for dist package in .gitattributes

Describe the solution you'd like


/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.laminas-ci.json export-ignore
/.travis.yml export-ignore
/benchmarks/ export-ignore
/docs/ export-ignore
/mkdocs.yml export-ignore
/phpbench.json export-ignore
/phpcs.xml export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/psalm-baseline.xml export-ignore
/renovate.json export-ignore
/test/ export-ignore

The form helpers are rendering an extra '%s'

Describe the bug

Printing an element in the traditional manner, with:

{{ formElement(profileForm.get('email') }}

Results in the printing of an extra %s character.

<div class="form-group">
    <input type="email" name="email" maxlength="254" required="required" autofocus="autofocus" placeholder="Email" class="forms_field-input form-control" value="">%s
</div>

To Reproduce

Steps to reproduce the behavior:

  1. Load TwbsHelper in application.config.php
  2. Create a simple form with this init method
    public function init()
    {
        $this->add([
            'name' => 'email',
            'id' => 'email',
            'type' => Email::class,
            'options' => [
                'label' => _("Your Email Address"),
                'label_attributes' => ['for' => 'email'],
            ],
            'attributes' => [
                'maxlength' => 254,
            ],
        ]);
    }
  1. Load the form object into a template, and print the form.

Expected behavior
The form is printed as expected.

Screenshots
https://imgur.com/a/X69TVNX

Desktop (please complete the following information):

  • OS: OSX Mojave
  • Browser Any
  • Version Any

Additional context

The error is caused by this block in TwbsHelper\Form\View\Helper\FormElement

    // Add a sprintf directive for correct render of errors
    if (!in_array($sElementType, $this->options->getIgnoredViewHelpers()) &&
        !($oElement instanceof Collection)
    ) {
        $sMarkup .= "%s";
    }

Label of radios are rendered at the end of the list.

Describe the bug
The label of a radio element is rendered at the end instead of at the top of a radiolist.

To Reproduce
Use example of https://neilime.github.io/twbs-helper-module/docs/usage/forms/checks-and-radios/#radios
Add 'label' for the element, eg: ['options']['label'] = 'Choose from the list below'

Actual behavior

o Default radio
o Default checked radio
Choose from the list below

Expected behavior

Choose from the list below
o Default radio
o Default checked radio

Migrating to PHP 7.4 can't use twbs form in template

Describe the bug
Trying to setup Laminas with Twbs module.

The \TwbsHelper\Form\View\Helper\Form is however not set in the template.

If I call

echo $this->container('100% wide until small breakpoint', 'sm');

it works.

But for some reason the $this->form is the Laminas Form instead of the Twbs one.

Composer:

{
...
    "require": {
        "php": ">=7.4",
        "laminas/laminas-authentication": "^2.12",
        "laminas/laminas-barcode": "^2.11",
        "laminas/laminas-cache": "^3.6",
        "laminas/laminas-cache-storage-adapter-memory": "*",
        "laminas/laminas-cache-storage-adapter-redis": "*",
        "laminas/laminas-captcha": "^2.14",
        "laminas/laminas-cli": "^1.5",
        "laminas/laminas-code": "^4.7",
        "laminas/laminas-component-installer": "*",
        "laminas/laminas-config": "^3.7",
        "laminas/laminas-console": "*",
        "laminas/laminas-crypt": "^3.8",
        "laminas/laminas-dependency-plugin": "^2.2",
        "laminas/laminas-development-mode": "^3.8",
        "laminas/laminas-di": "^3.9",
        "laminas/laminas-dom": "^2.12",
        "laminas/laminas-escaper": "^2.12",
        "laminas/laminas-eventmanager": "^3.5",
        "laminas/laminas-feed": "^2.18",
        "laminas/laminas-file": "^2.11",
        "laminas/laminas-filter": "^2.22",
        "laminas/laminas-form": "^3.4",
        "laminas/laminas-http": "^2.16",
        "laminas/laminas-i18n": "^2.17",
        "laminas/laminas-i18n-resources": "^2.8",
        "laminas/laminas-inputfilter": "^2.21",
        "laminas/laminas-json": "^3.3",
        "laminas/laminas-loader": "^2.8",
        "laminas/laminas-log": "^2.15",
        "laminas/laminas-mail": "^2.16",
        "laminas/laminas-math": "^3.5",
        "laminas/laminas-memory": "^2.9",
        "laminas/laminas-mime": "^2.10",
        "laminas/laminas-modulemanager": "^2.12",
        "laminas/laminas-mvc": "^3.3",
        "laminas/laminas-mvc-form": "^2.0",
        "laminas/laminas-mvc-middleware": "^2.2",
        "laminas/laminas-mvc-plugins": "^1.2",
        "laminas/laminas-navigation": "^2.15",
        "laminas/laminas-paginator": "^2.13",
        "laminas/laminas-permissions-acl": "^2.10",
        "laminas/laminas-permissions-rbac": "^3.3",
        "laminas/laminas-progressbar": "^2.10",
        "laminas/laminas-serializer": "^2.13",
        "laminas/laminas-server": "^2.11",
        "laminas/laminas-servicemanager": "^3.17",
        "laminas/laminas-session": "^2.13",
        "laminas/laminas-skeleton-installer": "^1.0",
        "laminas/laminas-soap": "^2.10",
        "laminas/laminas-stdlib": "^3.13",
        "laminas/laminas-tag": "^2.9",
        "laminas/laminas-test": "^4.3",
        "laminas/laminas-text": "^2.9",
        "laminas/laminas-uri": "^2.9",
        "laminas/laminas-validator": "^2.25",
        "laminas/laminas-view": "^2.23",
        "laminas/laminas-xml": "^1.4",
        "laminas/laminas-xmlrpc": "^2.14",
        "twbs/bootstrap": "*"
    }
}

Expected behavior
Expected the Twbs form to be used in the templates.

Screenshots
No screenshots, but the forms are not correct, as they are Laminas Forms.

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
Found a similar issue at #128, but that is using version laminas/laminas-servicemanager 3.6.*. Where as ours is locked to 3.17.

Thanks.

Regards,
Jarrett

Layout Horizontal not working?

Describe the bug
Have not been able to make a form display in horizontal layout. Adding

$this->setOption('layout', \TwbsHelper\Form\View\Helper\Form::LAYOUT_HORIZONTAL);

to the form class doesn't seem to work. The form is still displaying as inline. The class "row" is not added to the div.

To Reproduce
Steps to reproduce the behavior (have been using the Album tutorial to test):
create a form class and set the layout to horizontal

namespace Album\Form;

use Laminas\Form\Form;

class AlbumForm extends Form
{
    public function __construct($name = null)
    {
    
         // This did not work
        //$options['layout'] = \TwbsHelper\Form\View\Helper\Form::LAYOUT_HORIZONTAL;
        //parent::__construct('album-form', $options);

        //this also did not work
        parent::__construct('album-form');
        $this->setOption('layout', \TwbsHelper\Form\View\Helper\Form::LAYOUT_HORIZONTAL);

Rendering the form in a view with:

// module/Album/view/album/album/add.phtml:
$title = 'Add new album';
$this->headTitle($title);
?>
<h1><?= $this->escapeHtml($title) ?></h1>
<?php
$form->setAttribute('action', $this->url('album', ['action' => 'add']));
$form->prepare();

echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('title'));
echo $this->formRow($form->get('artist'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();

Expected behavior
Expected :

<div class="mb-3 row">
    <label class="form-label" for="title">Title</label>
    <input class="form-control" name="title" type="text" value="">

got:

<div class="mb-3">
    <label class="form-label" for="title">Title</label>
    <input class="form-control" name="title" type="text" value="">

Additional context
php: 8.0.8
laminas-form: 3.5.0
twbs-helper-module: 5.3.0
bootstrap 5.2.2

Possibility to disable "properIndentation"

Hi,

adding "ProperIndentation" leads to a bug in html structure in some rare cases. I'm not 100% sure how to reproduce this error with a generic example.

In my case, I have a very long form with one main fieldset containing two additional levels of fieldsets. For the second level of fieldsets the trailing "" are missing. So the whole form structure is wrong.

After adding return $sContent; on line 53 in function addProperIndentation in View/Helper/HtmlTrait.php everything works fine.
Another possibility to fix this error is to comment out line 74 to line 92. So it may be a problem related to exploding lines (line 61)

I know this is a very unspecific description, but unfortunately I cannot provide more details.
It would be great if indentation can be disabled. Its a very annoying problem related to a "nice to have" clean html code.

Best regards
Alexander

Size

Can you add the possibility of adding custom sizes?

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.