cakephp-3.0

Add custom class to CakePHP automagic date select

£可爱£侵袭症+ 提交于 2020-01-25 20:22:32
问题 I would like to add a class to all selects of an automagic created datepicker formgroup. <?= $this->Form->input('hide', ['class'=>'classtoadd' ]); ?> The result ist: <div class="input date"> <label>Hide</label> <select name="hide[year]"> <option value="" selected="selected"></option> <option value="2020">2020</option> ... </select> <select name="hide[month]"> <option value="" selected="selected"></option> <option value="01">Januar</option> ... </select> <select name="hide[day]"> <option value

Add custom class to CakePHP automagic date select

拈花ヽ惹草 提交于 2020-01-25 20:22:24
问题 I would like to add a class to all selects of an automagic created datepicker formgroup. <?= $this->Form->input('hide', ['class'=>'classtoadd' ]); ?> The result ist: <div class="input date"> <label>Hide</label> <select name="hide[year]"> <option value="" selected="selected"></option> <option value="2020">2020</option> ... </select> <select name="hide[month]"> <option value="" selected="selected"></option> <option value="01">Januar</option> ... </select> <select name="hide[day]"> <option value

CakePHP and FPDF: headers for view in browser

二次信任 提交于 2020-01-25 09:01:04
问题 I found many questions about which headers to use for download pdf files. Instead, I want to view them online (i.e. with the embedded Chrome plugin) and optionally download them with it. Here my code for CakePHP 3.7.9: pdf.ctp <?php header('Content-Type: application/pdf'); require_once(ROOT . DS . 'vendor' . DS . 'fpdf182' . DS . 'fpdf.php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); the related controller's function

CakePHP 3.5 Always apply asText() MySQL function to Spatial field

左心房为你撑大大i 提交于 2020-01-24 21:59:08
问题 I have a custom PolygonType which represents a POLYGON() field in a MySQL table. class PolygonType extends BaseType implements ExpressionTypeInterface { public function toPHP($value, Driver $d) { // $value is binary, requires unpack() } } I can use $query->func()->astext() on every find, but I would like to know if it's possible to always apply MySQL's AsText() function when selecting this field instead (similar to how toExpression() can be used when inserting data). 回答1: AFAIK there is no

CakePHP 3.5 Always apply asText() MySQL function to Spatial field

若如初见. 提交于 2020-01-24 21:58:06
问题 I have a custom PolygonType which represents a POLYGON() field in a MySQL table. class PolygonType extends BaseType implements ExpressionTypeInterface { public function toPHP($value, Driver $d) { // $value is binary, requires unpack() } } I can use $query->func()->astext() on every find, but I would like to know if it's possible to always apply MySQL's AsText() function when selecting this field instead (similar to how toExpression() can be used when inserting data). 回答1: AFAIK there is no

Can we add custom values to a CakePHP Table Object?

风格不统一 提交于 2020-01-24 19:10:08
问题 I have a Cake Object when querying a table: $invoices = TableRegistry::get('invoices')->find('all', ['conditions' => ['order_number =' => $orderNumber]]); This works fine. I then want to add other array key/values to this Object, like this one: $invoicesTmp = array(); $invoicesTmp['customer'] = "name of customer"; But $invoicesTmp is incompatible with $invoices. (one is an array, other is an CakePHP Object) I have tried this: compact($invoices, $invoicesTmp); but that didn't worked. 回答1: The

Where I store the custom exceptions in cakephp 3?

删除回忆录丶 提交于 2020-01-24 15:12:03
问题 I need to create a custom exception. But I dont have a clue where to store the file. In my opinion is app/Errors/NameException.php the right place. Is it? 回答1: That is a fine place to store your Exceptions. The final choice does not matter much as there is no convention set for this type of classes. The autoloader will find them anyway if you declare them correctly. 来源: https://stackoverflow.com/questions/27410054/where-i-store-the-custom-exceptions-in-cakephp-3

Where I store the custom exceptions in cakephp 3?

与世无争的帅哥 提交于 2020-01-24 15:09:32
问题 I need to create a custom exception. But I dont have a clue where to store the file. In my opinion is app/Errors/NameException.php the right place. Is it? 回答1: That is a fine place to store your Exceptions. The final choice does not matter much as there is no convention set for this type of classes. The autoloader will find them anyway if you declare them correctly. 来源: https://stackoverflow.com/questions/27410054/where-i-store-the-custom-exceptions-in-cakephp-3

cakephp 3.0 upgrade tool - Trouble understanding docs - Install tool where - folder to upgrade - where?

℡╲_俬逩灬. 提交于 2020-01-24 07:26:30
问题 I'm trying to convert 100 models + several hundred controllers & views from cakephp 2.6.7 to cakephp 3.0.7. I've tried the following with the upgrade shell tool: download the zip file place into project main folder (i.e. same folder that cake 2.6.7 app resides) php composer.phar install composer upgrade all. This installs all of cakePHP 3.0 Then the docs leave me with lots of questions... The upgrade tool provides a standalone application that can be used to upgrade other applications or

Cakephp 3 Unable to mark multiple checkboxes selected

与世无争的帅哥 提交于 2020-01-23 17:10:27
问题 My Edit view file has a set of checkboxes. I have managed to retrieve the selected checkbox values from the database, and want to mark these as selected in the view file. Edit view file <div class="col-md-12"> <?= $this->Form->label('category','Pick Categories');?> <?= $this->Form->select('category', $options,['multiple'=>'checkbox', 'required'=>'false', 'label'=>'Category','class'=>'col-md-12','selected'=>$catSel]); ?> </div> $options is $options = ['A'=>'Val1', 'B'=>'Val2', 'C'=>'Val3', 'D'