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

Empty rule and the input is CSS class required on submit #84

Open
spout opened this issue Jun 20, 2011 · 3 comments
Open

Empty rule and the input is CSS class required on submit #84

spout opened this issue Jun 20, 2011 · 3 comments

Comments

@spout
Copy link

spout commented Jun 20, 2011

I'm using MeioUpload (branch master) in CakePHP 1.3.10.

Photo isn't required, so I added the validate rule:
'photo' => array('Empty' => array('check' => false))

It works fine, but if I submit the form with no file upload but with other validations errors (on other fields), the file input get a CSS "required" class.
(class="input file required")
echo $this->Form->input('photo', array('type' => 'file'));
This happens only when the form is submitted, no required class without submitting the form.

I tried to put allowEmpty to false, it doesn't works too.

I don't know if it is a bug ?

@jrbasso
Copy link
Owner

jrbasso commented Jun 21, 2011

Not sure, because MeioUpload do not affect anything in views and model
validation. Probably is other thing.

Juan Basso

On Mon, Jun 20, 2011 at 9:56 AM, spout <
[email protected]>wrote:

I'm using MeioUpload (branch master) in CakePHP 1.3.10.

Photo isn't required, so I added the validate rule:
'photo' => array('Empty' => array('check' => false))

It works fine, but if I submit the form with no file upload but with
another validations errors (on other fields), the file input get a CSS
"required" class.
(class="input file required")
echo $this->Form->input('photo', array('type' => 'file'));

I tried to put allowEmpty to false, it doesn't works too.

I don't know if it is a bug ?

Reply to this email directly or view it on GitHub:
#84

@spout
Copy link
Author

spout commented Jun 21, 2011

Hello,
Thank you for the answer.
Now I've tested with Cake 1.3.10, 100% fresh install, the bug still happens:

/app/model/ad.php:


<?php 
class Ad extends AppModel{
    var $name = 'Ad';
    var $actsAs = array(
        'MeioUpload.MeioUpload' => array('photo')
    );

    var $validate = array(
        'title' => array(
            'required' => array('rule' => 'notEmpty', 'required' => true, 'message' => 'Title is required')
        ),
        'photo' => array(
            'Empty' => array('check' => false)
        ) 
    );
}
?>

/app/controllers/ads_controller.php:


<?php 
class AdsController extends AppController{
    function index($id = 0){
        if(empty($this->data)){
            $this->data = $this->Ad->findById($id);
        } 
        else{
            if($this->Ad->save($this->data)){
                $this->Session->setFlash("Saved!");
                $this->redirect('/ads');
            }
        }
    }   
}
?>

/app/views/ads/index.ctp:


<?php
echo $this->Form->create('Ad', array('type' => 'file'));
echo $this->Form->input('title');
echo $this->Form->input('photo', array('type' => 'file'));
echo $this->Form->end('Submit');
?>

Am I doing something wrong ?

@hugofcampos
Copy link

I still have the same issue. Does anyone knows if it was fixed?

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

No branches or pull requests

3 participants