{"id":113,"date":"2018-09-18T08:52:29","date_gmt":"2018-09-18T08:52:29","guid":{"rendered":"https:\/\/dapliw.org.ve\/misitio\/?p=113"},"modified":"2018-09-18T08:52:29","modified_gmt":"2018-09-18T08:52:29","slug":"cakephp-3-personalizar-la-etiqueta-de-un-select","status":"publish","type":"post","link":"https:\/\/saemas.com\/sitio_web\/cakephp-3-personalizar-la-etiqueta-de-un-select\/","title":{"rendered":"Cakephp 3 &#8211; Personalizar la etiqueta de un select"},"content":{"rendered":"<ul>\n<li>En el m\u00f3dulo entity agregamos:<\/li>\n<\/ul>\n<pre>protected function _getLabel()\n{\nreturn $this-&gt;_properties['nombreDelCampoX'] . ' - ' . $this-&gt;_properties['NombreDelCampoY'];\n}\n<\/pre>\n<ul>\n<li>En el controlador al hacer la b\u00fasqueda escribimos<\/li>\n<\/ul>\n<pre>$discounts = $this-&gt;Discounts-&gt;find('list', ['limit' =&gt; 200, \n  'order' =&gt; [\"discount_amount\" =&gt; \"ASC\"],\n  'keyField' =&gt; 'id', \n  'valueField' =&gt; function ($discount) \n  {\n    return $discount-&gt;get('label');\n  }]);\n<\/pre>\n<p>Fuente: <a href=\"https:\/\/book.cakephp.org\/3.0\/en\/orm\/retrieving-data-and-resultsets.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/book.cakephp.org\/3.0\/en\/orm\/retrieving-data-and-resultsets.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>En el m\u00f3dulo entity agregamos: protected function _getLabel() { return $this-&gt;_properties[&#8216;nombreDelCampoX&#8217;] . &#8216; &#8211; &#8216; . $this-&gt;_properties[&#8216;NombreDelCampoY&#8217;]; } En el controlador al hacer la b\u00fasqueda escribimos $discounts = $this-&gt;Discounts-&gt;find(&#8216;list&#8217;, [&#8216;limit&#8217; =&gt; 200, &#8216;order&#8217; =&gt; [\u00abdiscount_amount\u00bb =&gt; \u00abASC\u00bb], &#8216;keyField&#8217; =&gt; &#8216;id&#8217;, &#8216;valueField&#8217; =&gt; function ($discount) { return $discount-&gt;get(&#8216;label&#8217;); }]); Fuente: https:\/\/book.cakephp.org\/3.0\/en\/orm\/retrieving-data-and-resultsets.html<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"material-hide-sections":[],"footnotes":""},"categories":[11],"tags":[12],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-cakephp","tag-cakephp"],"_links":{"self":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":0,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"wp:attachment":[{"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saemas.com\/sitio_web\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}