Empty rule and the input is CSS class required on submit
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 ?
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: https://github.com/jrbasso/MeioUpload/issues/84
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 ?
I still have the same issue. Does anyone knows if it was fixed?