Log message #4221931

# At Username Text
# Jan 9th 2020, 19:32 dereuromark IMO helpers can do these things in specific cases, to avoid the overhead of component or cell involvement.
# Jan 9th 2020, 19:32 dereuromark wrapping it in a helper could make this at least isolated and testable
# Jan 9th 2020, 19:31 kailas it’s literally just one table function call.
# Jan 9th 2020, 19:30 kailas yeah, that’s what i was thinking
# Jan 9th 2020, 19:26 dereuromark Personally I find cells also a bit overhead if it is just a small data fetching (ready only).
# Jan 9th 2020, 19:26 dereuromark just dont tell anyone
# Jan 9th 2020, 19:25 dereuromark If you are aware of it, so be it :)
# Jan 9th 2020, 19:25 dereuromark In those cases one could use TableRegistry::get(), but still somewhat a code smell maybe
# Jan 9th 2020, 19:19 kailas is it possible to loadModel (or something like that) in a view Element? trying to get away with an element rather than a display cell but maybe this is when i should be using the cell?
# Jan 9th 2020, 16:11 val I added a somewhat related shim recently that may be interesting to you - https://github.com/dereuromark/cakephp-shim/blob/cake2/docs/View.md#formhelperinput-and-inputs
# Jan 9th 2020, 16:09 slackebot 'class' => 'col-sm-2 control-label', ] ); ?> <div class="col-sm-10"> <?php echo $this->Form->email('email', [ 'class' => 'form-control', 'value' => !empty($username) ? $username : '', 'placeholder' => __d('frontend', 'Email'), 'maxlength' => 180, ]); ?> </div> </div> ```
# Jan 9th 2020, 16:09 val An example. Before: ``` echo $this->Form->control('email', [ 'value' => !empty($username) ? $username : '', 'label' => [ 'text' => __d('frontend', 'Email'), 'class' => 'col-sm-2 control-label' ], 'placeholder' => __d('frontend', 'Email'), 'between' => '<div class="col-sm-10">', 'after' => '</div>', ]); ``` After:: ``` <div class="form-group row required"> <?php echo $this->Form->label( 'User.email', __d('frontend', 'Email'), [
# Jan 9th 2020, 16:08 val Yes, you can construct inputs semi-manually.
# Jan 9th 2020, 15:59 ricksaccous IT'S ALIVE
# Jan 9th 2020, 15:59 ricksaccous YES
# Jan 9th 2020, 15:54 neothermic yes!
# Jan 9th 2020, 15:50 neothermic hmm! *tries*
# Jan 9th 2020, 15:50 neothermic ah, I see an example!
# Jan 9th 2020, 15:49 neothermic eg:
# Jan 9th 2020, 15:49 neothermic that lets me insert arbitry items?
# Jan 9th 2020, 15:48 admad Yes, override th string templates
# Jan 9th 2020, 15:47 neothermic in cake2's form helper, you had the before/between/after for throwing stuff inbetween generated labels and inputs. Cake3 doesn't seem to have these anymore, is there a way to still do this?
# Jan 9th 2020, 15:27 admad @val test cases are the best examples
# Jan 9th 2020, 15:15 ricksaccous i dunno then, oh wells
# Jan 9th 2020, 15:15 ricksaccous that didn't work
# Jan 9th 2020, 15:15 ricksaccous welp
# Jan 9th 2020, 15:14 ricksaccous echo $this->Form->create(['well' => 'okay']); echo $this->Form->control('well'); echo $this->Form->end();
# Jan 9th 2020, 15:13 ricksaccous it would most likely match array key to array value
# Jan 9th 2020, 15:13 val to try what? `$this->Form->create([]);` ?
# Jan 9th 2020, 15:13 ricksaccous just try it, lell
# Jan 9th 2020, 15:13 val an example would be helpful
# Jan 9th 2020, 15:12 ricksaccous @val you could prob just set an array to the view if you want and use that
# Jan 9th 2020, 15:12 ricksaccous have you tried something and it failed?
# Jan 9th 2020, 15:06 val https://api.cakephp.org/3.8/class-Cake.View.Helper.FormHelper.html#_create ```The context for which the form is being defined. Can be a ContextInterface instance, ORM entity, ORM resultset, or an array of meta data.``` Is there an example when `$context` is an array of meta data? I cannot find it in the cookbook - https://book.cakephp.org/3/en/views/helpers/form.html#Cake\View\Helper\FormHelper::create
# Jan 9th 2020, 14:58 sdevore https://book.cakephp.org/3/en/orm/query-builder.html#sql-injection-prevention
# Jan 9th 2020, 14:47 ricksaccous you gotta bind those params
# Jan 9th 2020, 14:09 ndm Well, let's call it "(user) data", given that I don't know where `$id` comes from, but even if it's not user data currently (ie data sent by the user(agent) to your application), you never know when someone might make a change for the source of `$id`, so don't even start with inserting (user) data into queries directly.
# Jan 9th 2020, 14:06 alexdd55976 @ndm not sure what you mean with user data?
# Jan 9th 2020, 14:04 ndm @alexdd55976 It's still really bad form, never insert user data into queries if you can avoid it, always use bindings when possible, don't let stuff like that slip
# Jan 9th 2020, 14:03 alexdd55976 @sdevore thanks :)
# Jan 9th 2020, 14:02 sdevore Also https://book.cakephp.org/3/en/orm/query-builder.html#advanced-conditions there is a bit on notIn I have to run a kid to school but will be back in about an hour if you are still stuck ;) But I have faith that in my absence insight will be self discovered ;)