Comments (7)
Which is a method that calls the model EmpresaRegimen that doesn't exist. As far as I am concerned with standards, glue tables like that (only empresa_id and regimen_id being the fields) should not have model file. Or am I wrong in such interpretation?
Basically you're right, if you generate your models and CRUDs manually you can work around this issue and you do not have to generate models for the glue (pivot) tables.
But on the other hand you have to prepare your controllers to handle the saving of the related records. Yii 2 comes equipped with a link()
method which does most of the job for you, see also http://stackoverflow.com/a/26781976/291573
In giiant I decided to implement the generation of CRUDs in a very basic and generic way, which includes also the generation of CRUDs for the pivot tables.
The reason behind this decision is, that it is very hard to automate the generation of input and the saving of related data.
So for now, you'd have to generate a model for your pivot tables and then regenerate the CRUDs.
But I'll keep this issue open - it's on the roadmap to improve this.
from yii2-giiant.
In giiant I decided to implement the generation of CRUDs in a very basic and generic way, which includes also the generation of CRUDs for the pivot tables.
I see. Then, I am going to stick to the use of models for the pivot tables.
One question, though. Is the model the only thing neccesary or do I need to create a controller and views associated to the pivot tables?
Regards.
from yii2-giiant.
You need everything, but Giiant should do the whole job for you.
Please make sure you have a composite PK for your pivot table.
Usually I am creating the CRUD in a separate folder or module and don't them afterwards.
All customization is done through providers btw
Von meinem iPad gesendet
Am 17.02.2015 um 04:58 schrieb Carlos Ramos [email protected]:
In giiant I decided to implement the generation of CRUDs in a very basic and generic way, which includes also the generation of CRUDs for the pivot tables.
I see. Then, I am going to stick to the use of models for the pivot tables.
One question, though. Is the model the only thing neccesary or do I need to create a controller and views associated to the pivot tables?
Regards.
—
Reply to this email directly or view it on GitHub.
from yii2-giiant.
I'll try to setup a demo application to make things more clear.
from yii2-giiant.
Thanks for the info!
Please make sure you have a composite PK for your pivot table.
It seems that I lack more knowledge than what I thought at first u.u. I have not declared the composite key so far. In my migration, I have a foreign key relation to both tables, as:
$this->addForeignKey('empresa__regimen__e', 'empresa_regimen', 'empresa_id', 'empresa', 'id', 'RESTRICT', 'CASCADE');
$this->addForeignKey('empresa__regimen__r', 'empresa_regimen', 'regimen_id', 'regimen', 'id', 'RESTRICT', 'CASCADE');
Then I would need to declare the primary key as:
$this->addPrimaryKey('empresa_regimen_pk', 'empresa_regimen', 'empresa_id, regimen_id');
You need everything, but Giiant should do the whole job for you.
All customization is done through providers btw
So, I have to use the code generator (Giiant) to scaffold a lot of the code and then leave the base class alone forever. And all the database interactions I need would be done on the model that inherits from the base class, where I will start to use data providers to, well, provide the records.
So much new information. I think I have to read a Yii2 book before proceeding further.
And the demo would be more than welcome.
from yii2-giiant.
Here's the temporary demo:
http://playground-ee59a477-1.schmunk.cont.tutum.io:49160
admin/admin
Source:
https://github.com/phundament/playground
But I still need to review your latest comment...
from yii2-giiant.
New demo URL see: https://github.com/phundament/playground
Closing issue, please let me know if you've still have questions.
from yii2-giiant.
Related Issues (20)
- Generator name is empty ... Class c006\utility\migration\Module does not exist HOT 5
- Module Generator: Class 'insolita\wgadminlte\SmallBox' not found HOT 1
- CHANGELOG.md outdated HOT 1
- Unable to install - mismatch between giiant's required version for yii2-gii and current verions HOT 22
- How to create AccessFilter? HOT 8
- Unable to install @stable - Conflict betwwen Yii2-Gii and Current Version HOT 1
- Uncaught yii\console\Exception: Unknown option: --timestampBehaviorClass HOT 8
- --useSchemaName not implemented HOT 2
- Error using --providerList and possible fix HOT 18
- $aliasModel in model template HOT 4
- check dmstr dependencies
- .
- updated gii JSON form config path creates two bugs HOT 6
- Remove Bootstrap 3 To Bootstrap 4 HOT 1
- method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given HOT 3
- Error: Unknown option: --useTimestampBehavior. HOT 1
- type errors HOT 4
- Exception 'TypeError' with message 'key(): Argument #1 ($array) must be of type array, null given'
- Generating CRUD with via() and many-to-many relations gives an exception.
- useClassConstant not work HOT 2
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 yii2-giiant.