cakephp3-bootstrap-helpers icon indicating copy to clipboard operation
cakephp3-bootstrap-helpers copied to clipboard

Multiple file input

Open mvilskersts opened this issue 8 years ago • 5 comments

I believe there is a problem with bootstrap file input when using attribute "multiple".

In order to correctly upload multiple files i have to define my file input as array. For example: <?= $this->Form->input( 'images[]', [ 'multiple' => true, 'type' => 'file'] ); ?>

This creates the file upload widget that includes a fake input for displaying number of files chosen: <input type="text" name="images[]-text" class="form-control" readonly="readonly" id="images-input" onclick="document.getElementById('images').click();" value="">

Here is where the problem is: When I dump the contents of $_FILES super global variable all the chosen files are there as expected. However, if I dump $this->request->data one of the files is missing because the fake text input overrides it. What I propose is to replace readonlyattribute on the fake input with a disabled so that it doesn't get submitted (which proved to fix the issue for me).

mvilskersts avatar Jul 13 '17 05:07 mvilskersts

Are you sure this is the output your get for the text input? What happens if you change the name from images[] to images?

Holt59 avatar Jul 13 '17 09:07 Holt59

Same issue.. Any solution. Can't show error class in input value.

sathishsanthoshsusidhar avatar Jun 07 '19 09:06 sathishsanthoshsusidhar

@sathishsanthoshsusidhar Could you provide a bit more information? There is nothing related to error classes in the original issue.

Could you provide a piece of code that recreates the issue you're encountering? With what the actual output and what you expect.

Holt59 avatar Jun 07 '19 18:06 Holt59

image Code:

<?php foreach ($component->component_products as $key => $value) {
        echo $this->Form->control('component_products.'.$key.'.id',['type' => 'hidden','label' => false]);
        echo $this->Form->control('component_products.'.$key.'.product_id',['type'=> 'select','label' => false ,'empty' => 'Select','options' => $products]);
        echo $this->Form->control('component_products.'.$key.'.number_of_component', ['type' => 'number', 'label' => false]); 
        echo $this->Form->control('component_products.'.$key.'.spare_count', ['type' => 'number', 'label' => false]); 
        echo $this->Form->control('component_products.'.$key.'.start_product_no', ['type' => 'number', 'label' => false]); 
        echo $this->Form->control('component_products.'.$key.'.end_product_no', ['type' => 'number', 'label' => false]); 
} ?>

I add table row dynamically its working fine in add edit. But it not show the error message when i left empty. Is working one to one relation. Not working in hasMany.

How to solve it?

Thanks in Advance.

sathishsanthoshsusidhar avatar Jun 11 '19 11:06 sathishsanthoshsusidhar

@sathishsanthoshsusidhar This has nothing to do with a file input then, which is the whole purpose of this issue. I still do not really understand your problem... Could you open a new issue and add details on what you actually expect?

Your pictures has time-related columns, but the code you show speak of number of components, etc., so it does not seem related.

Holt59 avatar Jun 11 '19 11:06 Holt59