Part of the EllisLab Network
   
7 of 90
7
DMZ 1.7.1 (DataMapper OverZealous Edition)
Posted: 20 March 2010 04:42 AM   [ Ignore ]   [ # 61 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  335
Joined  10-18-2009

is it possible to use this with an already existing auth library without any conflict?

 Signature 

Wallpapers and Images Site: Desktop Wallpapers

Profile
 
 
Posted: 20 March 2010 12:41 PM   [ Ignore ]   [ # 62 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1041
Joined  10-08-2008

@Buso
DMZ is not an authorization library.  It’s an ORM.  But I can’t answer yes or no, you just have to set them up and try it.

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

Profile
 
 
Posted: 21 March 2010 02:33 AM   [ Ignore ]   [ # 63 ]  
Lab Assistant
RankRank
Total Posts:  200
Joined  04-02-2009

Im having a little problem with validation… here’s my code

if ($this->upload->do_upload("url"))
                    
{
                         $data 
=$this->upload->data();
                         
$a->url=$data['file_name'];
                    
}
                    
else
                    
{
                        $a
->error_message('custom'$this->upload->display_errors());
                    
}
                    
                    
if($a->save($t))
                    
{
                        $this
->session->set_flashdata('success''Tip Creado');
                        
redirect("Welcome");
                    
}
                    
//$a->error_message('custom', $this->upload->display_errors());  If I use it this way it works but I would preffer adding the error right after I catch it 

So want I want to do is add to the model validation errors the file upload error.. the problem is that (apparently) all errors get deleted when the save method is called… so if I set the error afterwards it does work cause it doesnt get deleted

Profile
 
 
Posted: 21 March 2010 10:47 AM   [ Ignore ]   [ # 64 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1041
Joined  10-08-2008

@NachoF

Why are you trying to save the object if there’s an error uploading?

if ($this->upload->do_upload("url")) {
    $data 
$this->upload->data();
    
$a->url $data['file_name'];
    if(
$a->save($t)) {
        $this
->session->set_flashdata('success''Tip Creado');
        
redirect("Welcome");
    
}
else {
    $a
->error_message('custom'$this->upload->display_errors());

Otherwise, what you are trying to do doesn’t make sense, anyway: if there are any validation errors, DMZ won’t save the object.  This means, if you set an error manually, (and the errors weren’t cleared) DMZ would never save. (That’s why it clears the errors before validating.)

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

Profile
 
 
Posted: 21 March 2010 02:14 PM   [ Ignore ]   [ # 65 ]  
Lab Assistant
RankRank
Total Posts:  200
Joined  04-02-2009

I try to save anyway cause I want all the errors listed in the form…. the form has many input text fields and the userfile to upload… I want the form to list all of the errors and the upload error as well….. with your code I will only get the upload error and not the rest of the errors of the form in the case that it couldnt upload the file.

Profile
 
 
Posted: 21 March 2010 02:21 PM   [ Ignore ]   [ # 66 ]  
Lab Assistant
RankRank
Total Posts:  287
Joined  06-18-2009

Why not create a function for every step? One to check all errors, one to check upload errors, one to save the data and one to render the page back. Complicated?

Profile
 
 
Posted: 21 March 2010 02:37 PM   [ Ignore ]   [ # 67 ]  
Lab Assistant
RankRank
Total Posts:  200
Joined  04-02-2009

Why would I do that at all?? have you used datamapper error validation???... it does all of that already.. the only problem Im having is when adding a custom error.. cause when the save method is called it deletes every error for that object.

Profile
 
 
Posted: 21 March 2010 02:37 PM   [ Ignore ]   [ # 68 ]  
Summer Student
Total Posts:  15
Joined  01-31-2010
NachoF - 21 March 2010 06:14 PM

I try to save anyway cause I want all the errors listed in the form…. the form has many input text fields and the userfile to upload… I want the form to list all of the errors and the upload error as well….. with your code I will only get the upload error and not the rest of the errors of the form in the case that it couldnt upload the file.

You could try this

// This is mostly Phil's code
if ($this->upload->do_upload("url")) {
    $data 
$this->upload->data();
    
$a->url $data['file_name'];
    if(
$a->save($t)) {
        $this
->session->set_flashdata('success''Tip Creado');
        
redirect("Welcome");
    
}
else {
    
// If the upload failed, this will validate the fields without saving the object
    
$a->validate(); 
    
// After validate has run you can append your custom errors
    
$a->error_message('custom'$this->upload->display_errors());
Profile
 
 
Posted: 21 March 2010 03:24 PM   [ Ignore ]   [ # 69 ]  
Lab Assistant
RankRank
Total Posts:  200
Joined  04-02-2009

Thank you that works.

Profile
 
 
Posted: 21 March 2010 11:13 PM   [ Ignore ]   [ # 70 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1041
Joined  10-08-2008

Announcing DataMapper OverZealous Edition 1.7.1

Download the Latest Version Here

  View the change log and the upgrade process
  Having issues? Please look through the Troubleshooting Guide & FAQs
  View the Complete Manual
  Search the Manual
  (Due to the server’s caching configuration, you may need to forcibly refresh your browser to see the changes in the manual.)

Version 1.7.1:
  • Various bug fixes
  • New method for seeing if two objects are already related
  • All extensions have been updated to use or accept get_iterated
  • Please see the change log for details.

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

Profile
 
 
   
7 of 90
7
 
‹‹ Twitter Search      Layouts and actions in CI ››