Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple file input #134

Open
mvilskersts opened this issue Jul 13, 2017 · 5 comments
Open

Multiple file input #134

mvilskersts opened this issue Jul 13, 2017 · 5 comments

Comments

@mvilskersts
Copy link

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).

@Holt59
Copy link
Collaborator

Holt59 commented Jul 13, 2017

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

@sathishsanthoshsusidhar
Copy link

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

@Holt59
Copy link
Collaborator

Holt59 commented Jun 7, 2019

@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.

@sathishsanthoshsusidhar
Copy link

sathishsanthoshsusidhar commented Jun 11, 2019

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.

@Holt59
Copy link
Collaborator

Holt59 commented Jun 11, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants