# |
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)? |
# |
Oct 5th 2016, 15:15 |
acosonic |
https://nimbus.everhelper.me/client/notes/share/599402/bxef2xmie4u1ikn3hgc9 |
# |
Oct 5th 2016, 15:13 |
admad |
cakenewb: so do it async. select2, selectize, chosen all this js plugins have the feature to populate list async |
# |
Oct 5th 2016, 15:13 |
cakenewb |
but the remote data seems to be doing just that! |
# |
Oct 5th 2016, 15:13 |
charolastra |
me too. generate a simple dropdown list and then apply that JS for a nice search field |
# |
Oct 5th 2016, 15:12 |
cakenewb |
thx acosonic, i'll check that. my main concern is performance. it would become quite slow I think whenever they have to load synchronously all addresses on each click of an order |
# |
Oct 5th 2016, 15:11 |
acosonic |
cakenewb: I've been using this... https://select2.github.io/ |
# |
Oct 5th 2016, 15:10 |
cakenewb |
are there examples available on how to do a search help/modal dialog box to search for an existing address which might be linked to a customer, or if it doesn't, create it and jump back into the order with the right address id? |
# |
Oct 5th 2016, 15:09 |
cakenewb |
having a select dropdown with 500 entries won't be very useful |
# |
Oct 5th 2016, 15:09 |
cakenewb |
for the address part |
# |
Oct 5th 2016, 15:08 |
cakenewb |
like order hasmany orderitems; order hasone address; order hasone customer; orderitems hasone product and hasone producttype |
# |
Oct 5th 2016, 15:08 |
cakenewb |
and more complex relations etc. |
# |
Oct 5th 2016, 15:07 |
cakenewb |
my applications had a few 100 records in all of its lifetime, now we're talking 100+ records per week |
# |
Oct 5th 2016, 15:05 |
acosonic |
Well Neon1024, can I PM you? |
# |
Oct 5th 2016, 15:05 |
Speud1 |
hi ;) |
# |
Oct 5th 2016, 15:05 |
Speud1 |
yes, it's always this kind of error with timestamp |