Log message #3942965

# At Username Text
# Oct 5th 2016, 17:14 Greezler Is there a reliable way I can use a PHP array (of integers) as a condition in a prepared statement?
# Oct 5th 2016, 17:01 ypnos you're welcome
# Oct 5th 2016, 17:01 francky06l I will give a try, Thanks a lot
# Oct 5th 2016, 17:01 francky06l I see, it's the "beforeValidate" of 2.x something like this ..
# Oct 5th 2016, 17:00 ypnos instead of properties you would have addresses
# Oct 5th 2016, 17:00 ypnos this would go into the User/Client table class
# Oct 5th 2016, 16:59 ypnos this is what I do in a similar problem
# Oct 5th 2016, 16:59 ypnos francky06l: https://gist.github.com/ypnos-web/af1f88fa18c148113cd4a88e495bb331
# Oct 5th 2016, 16:59 francky06l ~help
# Oct 5th 2016, 16:59 francky06l ~
# Oct 5th 2016, 16:59 francky06l ok, super :_)
# Oct 5th 2016, 16:58 ypnos francky06l: I have some example code for you
# Oct 5th 2016, 16:58 ypnos but for this you would need to do 2x hasOne instead of one hasMany
# Oct 5th 2016, 16:57 ypnos the other can be that you set a custom validator for the second association
# Oct 5th 2016, 16:57 ypnos that is probably the best solution to your problem
# Oct 5th 2016, 16:57 ypnos so you could throw out the second address in the request data if it is blank
# Oct 5th 2016, 16:57 francky06l I know :-) First it contains errors for the second address (wich is blank) ...
# Oct 5th 2016, 16:57 ypnos but you can work on the data before validation
# Oct 5th 2016, 16:56 ypnos no I just mention that this is what the validation is doing
# Oct 5th 2016, 16:56 francky06l So you suggest I should work on the request->data prior to "Entitize" them
# Oct 5th 2016, 16:55 ypnos I assume is your concern is that a second, associated address entity would be created even if not necessary
# Oct 5th 2016, 16:55 francky06l Basically I have 2 occurences of the Address Entity .. One of then can be blank (this ignored the validity rules of the Addresses table) ..
# Oct 5th 2016, 16:55 ypnos the marshalling happens before creation of entities which means that validation rules do not care if the field in question is associated or not
# Oct 5th 2016, 16:54 ypnos with secondary fields I just mean you say you have some fields (second address) that are subject to validation but need not be present. thats all I meant
# Oct 5th 2016, 16:54 ypnos yeah so the thing is
# Oct 5th 2016, 16:48 francky06l Well .. secondary fields ? But can you set allowEmpty in the form for the second address ? This is the problem ... because Addresses is not the main model it's an associated one
# Oct 5th 2016, 16:47 ypnos a combination of rules for the secondary fields with allowEmpty() should be all you need
# Oct 5th 2016, 16:46 ypnos maybe have a look at the tutorial? it has simple validation examples
# Oct 5th 2016, 16:46 francky06l I have been trough the doc already, but did not find a 'simple way' ... I am too new to 3.3
# Oct 5th 2016, 16:44 ypnos http://book.cakephp.org/3.0/en/core-libraries/validation.html
# Oct 5th 2016, 16:43 ypnos you can also use allowEmpty() and an entry containing only blanks might be catched by your validation rules?
# Oct 5th 2016, 16:43 ypnos also think about trimming, related problem
# Oct 5th 2016, 16:42 ypnos to avoid blank fields to fill database fields (i.e. to make the field NULL) you can use a filter method in the model that unsets blank values
# Oct 5th 2016, 16:41 ypnos validation is done in the model and there is a method for default validation (see the docs)
# Oct 5th 2016, 16:39 ypnos francky06l: just add the rules for validity of the secondary address fields and then also add ->allowBlank() for all of them
# Oct 5th 2016, 16:38 francky06l Migrating an app from 2.x to 3.3, People->hasMany('Addresses'), a Form with People and 2 Addresses (notEmpty(zip), notEmpty(street), 1 correct Address is mandatory second one if 'blank' should be ignored. Best way to validate this in 3.3 ? Thanks
# Oct 5th 2016, 16:31 francky06l Hi Bakers,
# Oct 5th 2016, 16:16 neothermic ooh, wait, does cakePHP 2.x support 5.3? My test has the new style arrays in it :S
# Oct 5th 2016, 15:17 acosonic cakenewb: its based on bootstrap
# Oct 5th 2016, 15:16 cakenewb that looks very nice indeed
# Oct 5th 2016, 15:15 cakenewb thanks acosonic and admad(/slackebot)?