# |
May 30th 2021, 13:55 |
etibor |
if the error message is displayed on the top of the page it would be also good |
# |
May 30th 2021, 13:55 |
etibor |
actually i have a field for total score, echo $this->Form->control( 'score' ); and if there is the custom error, the message is displayed there |
# |
May 30th 2021, 13:51 |
slackebot |
<kevin.pfeifer> |
# |
May 30th 2021, 13:51 |
kevin.pfeifer |
which results in |
# |
May 30th 2021, 13:51 |
kevin.pfeifer |
``` echo $this->Form->control( 'is_done' );``` |
# |
May 30th 2021, 13:50 |
kevin.pfeifer |
and my form outputs |
# |
May 30th 2021, 13:50 |
kevin.pfeifer |
in my Table |
# |
May 30th 2021, 13:50 |
kevin.pfeifer |
``` public function buildRules( RulesChecker $rules ): RulesChecker { $rules->add(function ($entity, $options) { return false; }, 'ruleName', [ 'errorField' => 'is_done', 'message' => 'My custom message' ]); return $rules; }``` |
# |
May 30th 2021, 13:50 |
kevin.pfeifer |
let me explain how I got it working |
# |
May 30th 2021, 13:47 |
etibor |
and the form is $this->Form->create($document) |
# |
May 30th 2021, 13:47 |
etibor |
$this->Form->control('storage.'.$i.'._joinData.score',['label'=>(false), 'type'=>'select','options'=>$options,'empty'=>__('choose') ]); |
# |
May 30th 2021, 13:45 |
kevin.pfeifer |
let me check that |
# |
May 30th 2021, 13:45 |
etibor |
but that does not show the erro by that field |
# |
May 30th 2021, 13:44 |
etibor |
i tried like this(just for give a try): ['errorField'=>'storage.0._joinData.score','message'=>'Do not change Form field values!'] |
# |
May 30th 2021, 13:43 |
etibor |
the fields look like this storage.$i._joinData.score |
# |
May 30th 2021, 13:42 |
kevin.pfeifer |
ha ok |
# |
May 30th 2021, 13:41 |
etibor |
the last thing would be to show the error message by the properly form field |
# |
May 30th 2021, 13:41 |
kevin.pfeifer |
hello :) |
# |
May 30th 2021, 13:41 |
etibor |
the solution almost work perfectly |
# |
May 30th 2021, 13:40 |
etibor |
hello Kevin |
# |
May 30th 2021, 08:26 |
kevin.pfeifer |
:clap: ndm |
# |
May 30th 2021, 04:17 |
admad |
@ndm You are already the north star of this channel for quite a while, guiding the lost souls. |
# |
May 30th 2021, 01:59 |
davinci |
nice!!! thanks! |
# |
May 30th 2021, 01:47 |
ndm |
Other than custom associations like those, the pretty much only other option would be to manually load the associated results in a result formatter, where you have access to the binding key values. You'd have to use something similar with row numbering window functions, or you'd have to run one additional query per parent, which kinda sucks @davinci |
# |
May 30th 2021, 01:39 |
ndm |
Now it's my time to shine :) https://github.com/icings/partitionable |
# |
May 30th 2021, 01:23 |
davinci |
I'm sure I'm missing something obvious, but can't think of it |
# |
May 30th 2021, 01:23 |
davinci |
Want to limit a contained data set to 10 Prices for each PriceSource, but doing it like this limits to 10 total: ```->contain([ 'PriceSources' => [ 'Prices' => function (Query $q) { return $q->where(['Prices.model'=>'Car', 'foreign_key'=>123456])->order(['Prices.date' => 'DESC'])->limit(10); }, ] ])``` |
# |
May 29th 2021, 22:50 |
kevin.pfeifer |
:+1::the_horns: |
# |
May 29th 2021, 22:47 |
etibor |
Kevin thank you really much i think the hard part is over, now i hope i will manage if not i will ask a little more help nex time |
# |
May 29th 2021, 22:43 |
kevin.pfeifer |
puh, dont really know. guess foreach |
# |
May 29th 2021, 22:42 |
etibor |
or is there an easier way? |
# |
May 29th 2021, 22:42 |
etibor |
should i go through wit a foreach ? |
# |
May 29th 2021, 22:41 |
etibor |
yes beacuse on the form there are multiple score form fields |
# |
May 29th 2021, 22:40 |
kevin.pfeifer |
but if at least you can get to the data ^^ |
# |
May 29th 2021, 22:40 |
kevin.pfeifer |
mhmm ok, could be that this is a difference from cake3 to 4 |
# |
May 29th 2021, 22:39 |
etibor |
the (false) data field is avaliable in a _joinData |
# |
May 29th 2021, 22:29 |
etibor |
moment please |
# |
May 29th 2021, 22:29 |
kevin.pfeifer |
before you call the save function |
# |
May 29th 2021, 22:28 |
kevin.pfeifer |
do you contain the storage model? |
# |
May 29th 2021, 22:28 |
kevin.pfeifer |
in your edit function |
# |
May 29th 2021, 22:28 |
kevin.pfeifer |
ok and in your controller |