Skip to content

Commit

Permalink
Fixes liferay#1285 - Add the input hidden with values the selected items
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Dec 4, 2018
1 parent 498fbcf commit 5956a75
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/clay-multi-select/src/ClayMultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@ ClayMultiSelect.STATE = {
*/
selectedItems: Config.array(Config.object()).value([]),

/**
* Name of the selected items input.
* @default undefind
* @instance
* @memberof ClayMultiSelect
* @type {?(string|undefined)}
*/
selectedItemsInputName: Config.string().value('selectedItems'),

/**
* The path to the SVG spritemap file containing the icons.
* @default undefined
Expand Down
18 changes: 17 additions & 1 deletion packages/clay-multi-select/src/ClayMultiSelect.soy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{@param? inputName: string}
{@param? label: string}
{@param? selectedItems: list<?>}
{@param? selectedItemsInputName: string}

{let $attributes kind="attributes"}
class="from-group
Expand Down Expand Up @@ -53,8 +54,9 @@
{param contentRenderer: $contentRenderer /}
{param filteredItems: $filteredItems /}
{param helpText: $helpText /}
{param inputName: $inputId /}
{param inputName: $inputName /}
{param selectedItems: $selectedItems /}
{param selectedItemsInputName: $selectedItemsInputName /}
{param spritemap: $spritemap /}
{/call}
</div>
Expand All @@ -73,6 +75,7 @@
{@param? filteredItems: list<?>}
{@param? inputName: string}
{@param? selectedItems: list<?>}
{@param? selectedItemsInputName: string}

{let $inputAttributes kind="attributes"}
class="form-control-inset"
Expand All @@ -97,6 +100,7 @@
{param _handleCloseButtonClick: $_handleCloseButtonClick /}
{param contentRenderer: $contentRenderer /}
{param selectedItems: $selectedItems /}
{param selectedItemsInputName: $selectedItemsInputName /}
{param spritemap: $spritemap /}
{/call}
{/if}
Expand Down Expand Up @@ -153,8 +157,20 @@
{@param spritemap: string}
{@param? _handleCloseButtonClick: any}
{@param? contentRenderer: string}
{@param? selectedItemsInputName: string}

{foreach $item in $selectedItems}
{let $inputAttributes kind="attributes"}
{if $selectedItemsInputName}
name="{$selectedItemsInputName}"
{/if}

type="hidden"
value="{$item.value}"
{/let}

<input {$inputAttributes}>

{delcall ClayMultiSelect.Item variant="$contentRenderer" allowemptydefault="true"}
{param _handleCloseButtonClick: $_handleCloseButtonClick /}
{param data: $item /}
Expand Down

0 comments on commit 5956a75

Please sign in to comment.