Log message #4019957

# At Username Text
# Apr 25th 2017, 09:20 dereuromark well, it is a generic cake basic, any field not just radios work the way I described above.
# Apr 25th 2017, 09:20 hagen00 so maybe that should e updated...
# Apr 25th 2017, 09:20 hagen00 don't say anything about setting a value to checked for radio
# Apr 25th 2017, 09:20 hagen00 but, just a final word on this. the docs here: https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-radio-buttons
# Apr 25th 2017, 09:20 neon1024 Morning everyone
# Apr 25th 2017, 09:19 hagen00 will fiddle. not your problem to solve!
# Apr 25th 2017, 09:19 hagen00 ok thanks :slightly_smiling_face:
# Apr 25th 2017, 09:19 dereuromark oh geeze :slightly_smiling_face: then use what I said above.
# Apr 25th 2017, 09:19 hagen00 it's an edit form
# Apr 25th 2017, 09:19 hagen00 i.e. radio...
# Apr 25th 2017, 09:19 hagen00 must be editable though
# Apr 25th 2017, 09:18 dereuromark most people wouldnt even use a radio here, just directly output icon + value
# Apr 25th 2017, 09:18 hagen00 that works, but it's ugly
# Apr 25th 2017, 09:18 dereuromark value= $entity->value
# Apr 25th 2017, 09:18 hagen00 echo $this->Form->radio( 'profile_category_questions._ids', [ ['value' => 'r', 'text' => 'Red', 'style' => 'color:red;'], ['value' => 'u', 'text' => 'Blue', 'style' => 'color:blue;', 'checked' => 'checked'], ['value' => 'g', 'text' => 'Green', 'style' => 'color:green;'], ] );
# Apr 25th 2017, 09:18 hagen00 maybe this:
# Apr 25th 2017, 09:18 dereuromark wuut? but then you can directly use entities?
# Apr 25th 2017, 09:18 hagen00 i have no problems with any of the controller things...
# Apr 25th 2017, 09:18 dereuromark and with cake3 even entities to do the same thing even cleaner
# Apr 25th 2017, 09:18 hagen00 ok, will look, but to be clear, i'm in the view .ctp file...
# Apr 25th 2017, 09:17 dereuromark there is an else case for if(posted)
# Apr 25th 2017, 09:17 dereuromark It works like it did 7 years ago :slightly_smiling_face: http://www.dereuromark.de/2010/06/23/working-with-forms/#default-values
# Apr 25th 2017, 09:16 dereuromark my point exactly
# Apr 25th 2017, 09:16 hagen00 i..e i'm landing on the page, requeste->data not set yet. no post request yet
# Apr 25th 2017, 09:16 hagen00 yes, i know that for simple forms. not sure it will work for a complex form, with multiple associations...
# Apr 25th 2017, 09:16 hagen00 hmm, but my array isn't populated from request->data.
# Apr 25th 2017, 09:15 dereuromark you can also populate the entity and do form->create($entity) - will also work and is even cleaner
# Apr 25th 2017, 09:15 dereuromark yes, and what I said is for displaying the selected value
# Apr 25th 2017, 09:14 dereuromark but I wouldnt do this with magic numbers, use either string keys, or better like I do a enum kind of approach
# Apr 25th 2017, 09:14 hagen00 i.e the form has been saved, now i want to display it again
# Apr 25th 2017, 09:14 hagen00 i'm asking for display purposes. not saving purposes
# Apr 25th 2017, 09:14 dereuromark it is really that easy
# Apr 25th 2017, 09:14 dereuromark $this->request->data[gender] = number
# Apr 25th 2017, 09:13 dereuromark if it is provided in the correct form
# Apr 25th 2017, 09:13 hagen00 how do i set Feminime to checked?
# Apr 25th 2017, 09:13 hagen00 so for example: $this->Form->radio('gender', ['Masculine','Feminine','Neuter']);
# Apr 25th 2017, 09:13 dereuromark why? it reads the data
# Apr 25th 2017, 09:13 hagen00 yes, i have the data. the data isn't the problem. the problem is the helper...
# Apr 25th 2017, 09:13 dereuromark either from controller via request->data preset, or in view via default
# Apr 25th 2017, 09:12 hagen00 https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-radio-buttons
# Apr 25th 2017, 09:12 hagen00 Can anyone advise how to set a radio button to checked in a radio button list. The docs aren't clear on this.