EllisLab text mark
Advanced Search
5 of 62
5
   
DMZ 1.7.1 (DataMapper OverZealous Edition)
Posted: 20 March 2010 05:42 AM   [ # 61 ]   [ Rating: 0 ]
Avatar
Joined: 2009-10-18
334 posts

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

 Signature 

Wallpapers and Images Site: Desktop Wallpapers

 
Posted: 20 March 2010 01:41 PM   [ # 62 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

@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

 
Posted: 21 March 2010 03:33 AM   [ # 63 ]   [ Rating: 0 ]
Joined: 2009-04-02
200 posts

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

 
Posted: 21 March 2010 11:47 AM   [ # 64 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

@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

 
Posted: 21 March 2010 03:14 PM   [ # 65 ]   [ Rating: 0 ]
Joined: 2009-04-02
200 posts

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.

 
Posted: 21 March 2010 03:21 PM   [ # 66 ]   [ Rating: 0 ]
Joined: 2009-06-18
279 posts

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?

 
Posted: 21 March 2010 03:37 PM   [ # 67 ]   [ Rating: 0 ]
Joined: 2009-04-02
200 posts

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.

 
Posted: 21 March 2010 03:37 PM   [ # 68 ]   [ Rating: 0 ]
Joined: 2010-01-31
15 posts
NachoF - 21 March 2010 07: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());
 
Posted: 21 March 2010 04:24 PM   [ # 69 ]   [ Rating: 0 ]
Joined: 2009-04-02
200 posts

Thank you that works.

 
Posted: 22 March 2010 12:13 AM   [ # 70 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

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

 
Posted: 22 March 2010 04:05 AM   [ # 71 ]   [ Rating: 0 ]
Joined: 2009-06-18
279 posts

woohoo, nice :D

Congrats, I’ll definitely update my version.

 
Posted: 22 March 2010 05:46 AM   [ # 72 ]   [ Rating: 0 ]
Joined: 2009-03-21
34 posts

HTML Table extension for DMZ.

Features are:
- label from $validation / custom label
- mapping by $validation[‘field’][‘values’] / custom array mapping
- custom function-generated fields
- autopagination with native CI paginator when _paged

ATTENTION: this extension is third-party, so don’t bother Phill with questions about it.

Forum thread.

Here is homebrew extension, that works in similar way as original HTML Form extension,
but doesn’t have so much features at the moment.

All it does is provide render_table() method that builds html code based on settings given by user. It can save some time for you and make table-generation part of the view more readable. Extension is shipped with two table templates: object_per_row and object_per_column.

DOES NOT support _iterated at the moment.

Docs included in distrib.

html_table_for_dmz.zip

 Signature 

HTML Table extension for Datamapper Overzealous

 
Posted: 22 March 2010 11:22 AM   [ # 73 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

@Oblique
If you have a moment, you should add your extension to the Wiki category.  The DMZ Extensions page is now linked-to from the docs, so it helps make it more discoverable.

If you need any help making changes to support the _iterated methods, let me know!

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

 
Posted: 22 March 2010 12:22 PM   [ # 74 ]   [ Rating: 0 ]
Joined: 2009-03-21
34 posts

Yeah, made page, but forgot to add category.

Damn, building docs is sooo tedious.

I know there is way to make it fun and joyful.
Please somebody tell me about it.
Phill?

Some WYSIWYG maybe? Markup by hands in NB is boring )

@OverZealous
Yeah, looks like now it depends almost completely on _iterated support, whether will it or will it not be needed )

Uh. Well, i think i know how to make it work, but first i need to know that someone needs it ) Or when i will need it myself. Tired of making things just for gaining exp )

 Signature 

HTML Table extension for Datamapper Overzealous

 
Posted: 22 March 2010 12:29 PM   [ # 75 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

@Oblique

The reality of software development—and they don’t tell you this in college—is that writing code makes up at most 5-10% of your time.  Design and planning, for me, take up about 25%, testing and debugging probably 25-50%, and the leftover time is pretty much all documenting.*

When I did the original rewrite of the DataMapper docs, it took me over 40 hours of work!  I still spend almost equal amounts of time managing the manual as I do the code.

As far as I know, there is no way to make documentation fun.  If you like writing, that helps.  If you love your project, writing about it is a little exciting, because you get to show off your work.  Undocumented code might as well not exist; documented code is there for all the world to appreciate.

Maybe if you think of it that way it helps.

* Numbers in the post are completely made up.  Your numbers may vary based on actual time spent.  Project and team size can be a factor in determining your time usage.  Results not guaranteed.

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

 
5 of 62
5