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

Extension for typiCMS #154

Open
visermort opened this issue Oct 16, 2019 · 12 comments
Open

Extension for typiCMS #154

visermort opened this issue Oct 16, 2019 · 12 comments

Comments

@visermort
Copy link

Hello! Extension https://packagist.org/packages/visermort/typimultiinput
Is it useful do you think? How could it be improved?

@sdebacker
Copy link
Contributor

Hello, thanks for sharing. I will try it when I have some time, but yes it's a good idea to make it a plugin.

@ivarsmednis
Copy link

Great work Visemort! Reusable repeatables are needed feature!

The only problem i got was getting error, when trying to add multiinput while creating item by clicking "Add" button. This is error i am getting https://jmp.sh/yS0T6bC

After item is created, it works nicely in edit mode (didn't try all the features yet).

Only thing that i see for improvement would be adding some visual/usability tweaks, like padding between fields and cards and maybe zebra colored rows?
Try adding classes "table table-striped" to your "multiinput-body" table and bootstrap will take care automatically and will look nice!

Thanks for your work!

@ivarsmednis
Copy link

For more distinctive title (it is different section with subsections after all) you can add class="h4" to your multiinput-header -> label

then it will look like this https://jmp.sh/SMGlF2C

@visermort
Copy link
Author

visermort commented Oct 17, 2019

Thank You!

The only problem i got was getting error, when trying to add multiinput while creating item by clicking "Add" button. This is error i am getting https://jmp.sh/yS0T6bC

Can you describe when the error occurs. I'm trying to repeat it..

Try adding classes "table table-striped" to your "multiinput-body" table and bootstrap will take care automatically and will look nice!

Yes, a good idea

For more distinctive title (it is different section with subsections after all) you can add class="h4" to your multiinput-header -> label

Yes, may be h4 or h5. And one can put component to other tab on a form.

@ivarsmednis
Copy link

What i did was clean Typicms install, then created products module via artisan. then applied instruction from your readme.
Here is my config

`<?php

define('MULTIINPUT_STATUS_WAITING', 0);
define('MULTIINPUT_STATUS_ACTIVE', 1);
define('MULTIINPUT_STATUS_DISABLE', 2);

$activeLabels = [
MULTIINPUT_STATUS_WAITING => "Waiting",
MULTIINPUT_STATUS_ACTIVE => "Active",
MULTIINPUT_STATUS_DISABLE => "Disable",
];

return [
//configName
'advantages' => [
"single-row" => false,
"title" => "Advantages",
"order" => [
"sort" => "ASC",
"title" => "ASC"
],
"columns" => [
[
"name" => "title",
"title" => "Title",
"type" => "Varchar",
"translatable" => false,
'rules' => 'required|max:255',
],

        [
            "name" => "feature_image",
            "title" => "Feature Image",
            "type" => "Image"
        ],

        [
            "name" => "viewed",
            "title" => "Viewed",
            "type" => "Boolean",
            "translatable" => false
        ],


    ]
],

];
`

The error is only when inserting new row in products table. When i edit existing row - working nicely.

@ivarsmednis
Copy link

Its not a big problem since i could only show this field in admin, when editing a product record

@visermort visermort reopened this Oct 17, 2019
@visermort
Copy link
Author

Its not a big problem since i could only show this field in admin, when editing a product record

Error is fixed. It is need to update a model class (see update in manual)
All wishes are realized.

@ivarsmednis
Copy link

Great work!
Visemort, is it possible to make dropdown from related table items? Would be cool if i could pass some data from admin view (just like bootform selects).

@visermort
Copy link
Author

visermort commented Oct 22, 2019

Great work!
Visemort, is it possible to make dropdown from related table items? Would be cool if i could pass some data from admin view (just like bootform selects).

Hi! Thank you!
Now it is possible to update config from form.
For example: {!! MultiInput::render('advantages', 'advantages', $model, ['columns' => ['templates' => ['items' => TypiCMS::templates()]]]) !!}
and pass this array to ::publish() too.
It would be fine if you will continue to use. May be there are some bugs I have not caught.

@ivarsmednis
Copy link

Visemort, everything is working nicely so far except one thing with dropdown. I can't get it to have selected item and admin dropdown is not remembering selected value. All works nicely if i define dropdown in config. But when i override it from view, it reneders dropdown options but none is selected.

it save to database correctly but not reading selected value.

here is the code (i also tried with your example templates code - same result).

    {!! MultiInput::render('data', 'pagelinks', $model, ['columns' => ['pages' => [
            'items' => Pages::all()->sortBy('title')->pluck('title', 'id')->toArray(),
            "name" => "pageId",
            "title" => "Pages",
            "type" => "Dropdown",
            "translatable" => false,
        ]]]) !!}

@visermort
Copy link
Author

visermort commented Nov 18, 2019

Visemort, everything is working nicely so far except one thing with dropdown. I can't get it to have selected item and admin dropdown is not remembering selected value. All works nicely if i define dropdown in config. But when i override it from view, it reneders dropdown options but none is selected.

it save to database correctly but not reading selected value.

here is the code (i also tried with your example templates code - same result).

    {!! MultiInput::render('data', 'pagelinks', $model, ['columns' => ['pages' => [
            'items' => Pages::all()->sortBy('title')->pluck('title', 'id')->toArray(),
            "name" => "pageId",
            "title" => "Pages",
            "type" => "Dropdown",
            "translatable" => false,
        ]]]) !!}

Hello.
I tried
{!! MultiInput::render('advantages', 'advantages', $model, ['columns' => ['pages' => [
'items' => Pages::all()->sortBy('title')->pluck('title', 'id')->toArray(),
"name" => "pages",
"title" => "Pages",
"type" => "Dropdown",
]]]) !!}
and works well.
When we override config in template, extension does array_merge_recursive(<base_config>, <conifg_from-template>)
In this case key "pages" must be the same with "name"=> "pages" as well.
I will thange arrray_merge_recursive with other method.

@ivarsmednis
Copy link

You are right, this way its working perfect! Thank you!

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

No branches or pull requests

3 participants