Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Dropdown box fields problems #11

Open
mittus opened this issue Sep 2, 2018 · 8 comments
Open

Dropdown box fields problems #11

mittus opened this issue Sep 2, 2018 · 8 comments
Milestone

Comments

@mittus
Copy link

mittus commented Sep 2, 2018

If I save empty values with spase (not a  ), in the items, when I try save them, I see error "Invalid value format for the Fieldtype"

@bigin
Copy link
Owner

bigin commented Sep 2, 2018

I don't understand, could you please describe it better or give more information? Thank you

@mittus
Copy link
Author

mittus commented Sep 2, 2018

  1. I create new field, and use space-bar (If I create field with &bpsp;, it have not problem)
    screenshot_5
  2. When I save any item, I get error:
    screenshot_7
    screenshot_8

@bigin
Copy link
Owner

bigin commented Sep 2, 2018

Ah yes that I know, unfortunately it is so for the moment, because it trims the spaces when entering the value in the item editor. Can you use   or is there a problem?

@mittus
Copy link
Author

mittus commented Sep 3, 2018

Yes, with   I can and it is not problem.

@bigin bigin added this to the Priority: low milestone Sep 4, 2018
@bigin bigin removed the help wanted label Jan 9, 2019
@mittus
Copy link
Author

mittus commented Mar 11, 2019

Hello!! How I can use multiple dropdown for select several values?

@bigin
Copy link
Owner

bigin commented Mar 13, 2019

Hi mittus!

Unfortunately, we currently have no way to accomplish this. You can use a chunk field or write your own field type that allows it.

With a chunk field it should be relatively easy, for example:

  1. Create a text field, name it cars. Give this field area CSS class hidden.
  2. Create a chunk field with default value:
<div class="fieldarea">
<label for="multiple_dropdown">Select Multiple</label>	
<div class="field-wrapper">
<select id="selectMultiple" multiple>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
</div>
</div>
<script>
$(function() {
    var values = $("#cars").val();
    $.each(values.split(","), function(i,e){
        $("select#selectMultiple option[value='" + e + "']").prop("selected", true);
    });
    $("select#selectMultiple").change(function(e) {
        var selected = $(e.target).val();
        $("#cars").val(selected);
        console.log($("#cars").val())
    }); 
});
</script>

Sometime I will extend ItemManager with the new field, unfortunately I don't have time for it now ;-)

@mittus
Copy link
Author

mittus commented Mar 14, 2019

Hello!

I need use my own field. Now trying create multiple field. If you have example, give me please.

Thank You!!

@bigin
Copy link
Owner

bigin commented Mar 14, 2019

Here are the files you can duplicate and customize:
imanager/lib/processors/fields/FieldDropdown.php
imanager/lib/processors/inputs/InputDropdown.php

Since these fields also implement InputText, take a look at the imanager/lib/processors/inputs/InputText.php file.

And you still have to adjust your backend template file /plugins/imanager/tpl/row.fields.im.tpl.

You can also find more information here: https://ehret-studio.com/articles/itemmanager/itemmanager-fieldtypes/

Good luck! ;-)

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

No branches or pull requests

2 participants