Comments (5)
I wasn't able to reproduce this with the following table:
CREATE TABLE `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
)
I ran
bin/cake bake model categories
bin/cake bake controller categories
bin/cake bake template categories
The generated controller contained
/**
* Add method
*
* @return void Redirects on successful add, renders view otherwise.
*/
public function add()
{
$category = $this->Categories->newEntity();
if ($this->request->is('post')) {
$category = $this->Categories->patchEntity($category, $this->request->data);
if ($this->Categories->save($category)) {
$this->Flash->success(__('The category has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The category could not be saved. Please, try again.'));
}
}
$parentCategories = $this->Categories->ParentCategories->find('list', ['limit' => 200]);
$this->set(compact('category', 'parentCategories'));
$this->set('_serialize', ['category']);
}
And the add form contained
<?= $this->Form->create($category) ?>
<fieldset>
<legend><?= __('Add Category') ?></legend>
<?php
echo $this->Form->input('parent_id', ['options' => $parentCategories, 'empty' => true]);
echo $this->Form->input('title');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
As did the edit form.
from bake.
That's weird.
The same example with bake 1.0.9, cake 3.0.7 and the baked add form looks like that:
<?= $this->Form->create($category) ?>
<fieldset>
<legend><?= __('Add Category') ?></legend>
<?php
echo $this->Form->input('parent_id');
echo $this->Form->input('title');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
I'm using php 5.5.9 and mysql 5.5.43
from bake.
I tried with master
. I can do a release for bake today.
from bake.
Just for the record - it works with master on my side too now.
from bake.
huzzah
from bake.
Related Issues (20)
- Pending task for Cake 5
- RFC: Do not generate associations for `_id` fields if no Table object or database table present HOT 3
- Bug found in 2.8.0 - Error when baking component `Twig\Error\SyntaxError` HOT 1
- Baking Middleware should bake Middleware tests HOT 1
- `--datasource` alias to `--connection` for consistency HOT 2
- 2.x: Dirty state after tests HOT 3
- DisplayField does not fallback to `*_name` field HOT 1
- Allow passing multiple model names HOT 1
- Incorrect message when `plugins` directory not exists using bake HOT 13
- Column with *_id not generating a `belongsTo` relation anymore. HOT 2
- bake not override plugins bake template HOT 4
- Return value of Bake\Command\ModelCommand::getDisplayField() must be of the type string or null, array returned in HOT 6
- [3.x] Adaption to the new behavior of `EntityTrait::has()` HOT 5
- Wrong signature for get() in table classes HOT 2
- RFC: generics for array collections? HOT 2
- Cannot bake ControllerTest with model type other than Table HOT 9
- Application/Validation rule issues HOT 3
- Baked enum docblock wrong
- Baking snapshot with autoid HOT 5
- Bake snapshot losing structure data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bake.