Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should gii use bootstrap5 assets since both basic and advanced apps are already using it? #528

Open
atrandafir opened this issue May 22, 2023 · 3 comments

Comments

@atrandafir
Copy link

atrandafir commented May 22, 2023

What steps will reproduce the problem?

  1. Create new application either basic or advanced
  2. Create some tables in your database and generate the models
  3. Generate CRUD with gii

What's expected?

  • To get bootstrap5 classes on all the generated views, especially forms, should be calling yii\bootstrap5\ActiveForm;

What do you get instead?

  • I get default Yii widgets such as yii\widgets\ActiveForm

Additional info

Q A
Yii version 2.0.47
PHP version 8.0.17
Database version MariaDB
Operating system Windows 11

Comments

I'm wondering if I am doing something wrong. But if not, I think it would be a nice user experience to start the project directly with the right bootstrap version.

I am willing to create a PR for gii if we decide upon a solution. Maybe we could add multiple generator templates for each bootstrap version and ask the user to choose it before generating crud/views?

@schmunk42
Copy link
Contributor

If implemented, it should go into a separate folder here https://github.com/yiisoft/yii2-gii/tree/master/src/generators/crud
But we'd have to maintain two sets of views then.

I think this should be left to an extension, since it's basically a configuration thing for your current project.

Or ... the app-templates should provide the corresponding CRUD templates.

@atrandafir
Copy link
Author

I have forked the repo and did some playing around to see what would be a good solution.

I've ended up with something like this:
image

You can see the commit here (it is not finished yet):
atrandafir@6ae6a69

Apparently the only things that can change depending on bootstrap version, are the php classes, or the html classes generated in the views. So with some setup like this, there would be no need to maintain multiple views, because the rest of the code would not change.

Also with this in the future maybe even someone could use a different framework than Bootstrap, and configure gii and map all the classes to the corresponding ones.

Currently some stuff is breaking from bs 3 that I think was used initially, to bs 5. Mostly the forms "break" because the classes do not match anymore. But the GridView does not seem to break, at least not for now, but maybe in the future it will, and it would be required to be included into https://github.com/yiisoft/yii2-bootstrap5 repo.

@schmunk42
Copy link
Contributor

This current views are barebone HTML, I do not think it's a viable way just to re-map some CSS and PHP classes.
In theory it would be nice, but CSS frameworks also rely on markup sometimes.

You can simply provide your own templates, see https://github.com/yiisoft/yii2-gii/blob/master/docs/guide/topics-creating-your-own-templates.md

For an example how to further extend gii, have a look at https://github.com/schmunk42/yii2-giiant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants