Skip to content
Snippets Groups Projects
Commit d0bb9a56 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge pull request #1913 from protich/issue/list-item-lookup


bug: Consider list when looking up list item

Reviewed-By: default avatarJared Hancock <jared@osticket.com>
parents 9ee12a9a fc1a56ea
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,8 @@ class DynamicFormsAjaxAPI extends AjaxController {
$item->extra = $basic['extra'];
$item->value = $basic['value'];
if ($_item = DynamicListItem::lookup(array('value'=>$item->value)))
if ($_item = DynamicListItem::lookup(array(
'list_id' => $list->getId(), 'value'=>$item->value)))
if ($_item && $_item->id != $item->id)
$item_form->getField('value')->addError(
__('Value already in use'));
......@@ -218,11 +219,12 @@ class DynamicFormsAjaxAPI extends AjaxController {
if ($_POST && ($valid = $item_form->isValid())) {
$data = $item_form->getClean();
if ($_item = DynamicListItem::lookup(array('value'=>$data['value'])))
if ($_item = DynamicListItem::lookup(array(
'list_id' => $list->getId(), 'value'=>$data['value'])))
if ($_item && $_item->id)
$item_form->getField('value')->addError(
__('Value already in use'));
$data['list_id'] = $list_id;
$data['list_id'] = $list->getId();
$item = DynamicListItem::create($data);
if ($item->save() && $item->setConfiguration())
Http::response(201, $this->encode(array('success' => true)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment