Part of the EllisLab Network
   
90 of 90
90
DMZ 1.7.1 (DataMapper OverZealous Edition)
Posted: 29 November 2011 02:07 AM   [ Ignore ]   [ # 891 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

DataMapper doesn’t do anything with repopulating forms, why would a repopulation issue be related to DataMapper?

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
Posted: 04 December 2011 04:26 AM   [ Ignore ]   [ # 892 ]  
Grad Student
Rank
Total Posts:  47
Joined  10-16-2008

As far as I have seen, DataMapper doesn’t run CI’ FormValidation rules by calling run(), it calls the rule function directly instead. This causes the FormValidation library not to store the _field_data array, which in turn, disables set_value() ability to repopulate the form.

I’m not saying it’s wrong, I just want to find a workaround to deal with this.

Profile
 
 
Posted: 04 December 2011 04:54 AM   [ Ignore ]   [ # 893 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

DataMapper doesn’t do form validation at all.

It does pre-save validation of object properties. And yes, some of the validation rules are borrowed from the form validation library. But that doesn’t mean it is the same as form validation.

If you want to populate your forms from DataMapper objects, just use the object properties directly. If you need default values for new objects, add a method to your model that sets them when not exists(), and call that method before you load the view. Alternatively, you can call it from __construct() (and probably clear() as well) to do it automatically.

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
Posted: 04 December 2011 05:01 AM   [ Ignore ]   [ # 894 ]  
Grad Student
Rank
Total Posts:  47
Joined  10-16-2008
WanWizard - 04 December 2011 04:54 AM

DataMapper doesn’t do form validation at all.

That’s confusing, taking into account what says here: http://datamapper.wanwizard.eu/pages/validation.html

Profile
 
 
Posted: 04 December 2011 05:36 AM   [ Ignore ]   [ # 895 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

I don’t think that page says any different from what I just wrote, nor does it say it does something with forms.

What exactly is confusing?

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

Profile
 
 
Posted: 04 December 2011 09:49 PM   [ Ignore ]   [ # 896 ]  
Grad Student
Rank
Total Posts:  47
Joined  10-16-2008

You say that DataMapper doesn’t do any form validation at all, but the user guide says it does, so that’s confusing to me. Please explain a bit better (and thank you for your patience)

Profile
 
 
Posted: 05 December 2011 03:48 AM   [ Ignore ]   [ # 897 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  4108
Joined  11-04-2008

No, the user guide says that DataMapper provides object property validation.

It runs validation rules on the object properties before you save the object (i.e. INSERT or UPDATE the record). It is not about POSTed variables at all, forms or form variables are not mentioned on that page.

It only says that DataMapper is “borrowing some of the existing functionality from the CodeIgniter Form Validation library.” which means that for example DataMapper doesn’t provide it’s own valid_email() method, but instead calls the method in the form validation library.

 Signature 

WanWizard.eu | Modular CI, an HMVC solution | DataMapper ORM

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