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

Fix clobber of property and list item sorting

parent 3386a216
No related branches found
No related tags found
No related merge requests found
...@@ -99,7 +99,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -99,7 +99,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<i class="help-tip icon-question-sign" href="#field_delete"></i></th> <i class="help-tip icon-question-sign" href="#field_delete"></i></th>
</tr> </tr>
</thead> </thead>
<tbody class="sortable-rows" data-sort="sort-"> <tbody class="sortable-rows" data-sort="prop-sort-">
<?php if ($form) foreach ($form->getDynamicFields() as $f) { <?php if ($form) foreach ($form->getDynamicFields() as $f) {
$id = $f->get('id'); $id = $f->get('id');
$deletable = !$f->isDeletable() ? 'disabled="disabled"' : ''; $deletable = !$f->isDeletable() ? 'disabled="disabled"' : '';
...@@ -108,7 +108,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -108,7 +108,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
$ferrors = $f->errors(); ?> $ferrors = $f->errors(); ?>
<tr> <tr>
<td><i class="icon-sort"></i></td> <td><i class="icon-sort"></i></td>
<td><input type="text" size="32" name="label-<?php echo $id; ?>" <td><input type="text" size="32" name="prop-label-<?php echo $id; ?>"
value="<?php echo Format::htmlchars($f->get('label')); ?>"/> value="<?php echo Format::htmlchars($f->get('label')); ?>"/>
<font class="error"><?php <font class="error"><?php
if ($ferrors['label']) echo '<br/>'; echo $ferrors['label']; ?> if ($ferrors['label']) echo '<br/>'; echo $ferrors['label']; ?>
...@@ -148,7 +148,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -148,7 +148,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
</td> </td>
<td><input type="checkbox" name="delete-<?php echo $id; ?>" <td><input type="checkbox" name="delete-<?php echo $id; ?>"
<?php echo $deletable; ?>/> <?php echo $deletable; ?>/>
<input type="hidden" name="sort-<?php echo $id; ?>" <input type="hidden" name="prop-sort-<?php echo $id; ?>"
value="<?php echo $f->get('sort'); ?>"/> value="<?php echo $f->get('sort'); ?>"/>
</td> </td>
</tr> </tr>
...@@ -156,10 +156,10 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -156,10 +156,10 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
} }
for ($i=0; $i<$newcount; $i++) { ?> for ($i=0; $i<$newcount; $i++) { ?>
<td><em>+</em> <td><em>+</em>
<input type="hidden" name="sort-new-<?php echo $i; ?>" <input type="hidden" name="prop-sort-new-<?php echo $i; ?>"
value="<?php echo $info["sort-new-$i"]; ?>"/></td> value="<?php echo $info["prop-sort-new-$i"]; ?>"/></td>
<td><input type="text" size="32" name="label-new-<?php echo $i; ?>" <td><input type="text" size="32" name="prop-label-new-<?php echo $i; ?>"
value="<?php echo $info["label-new-$i"]; ?>"/></td> value="<?php echo $info["prop-label-new-$i"]; ?>"/></td>
<td><select name="type-new-<?php echo $i; ?>"> <td><select name="type-new-<?php echo $i; ?>">
<?php foreach (FormField::allTypes() as $group=>$types) { <?php foreach (FormField::allTypes() as $group=>$types) {
?><optgroup label="<?php echo Format::htmlchars($group); ?>"><?php ?><optgroup label="<?php echo Format::htmlchars($group); ?>"><?php
......
...@@ -61,8 +61,8 @@ if($_POST) { ...@@ -61,8 +61,8 @@ if($_POST) {
$field->set('name', $_POST["name-$id"]); $field->set('name', $_POST["name-$id"]);
# TODO: make sure all help topics still have all required fields # TODO: make sure all help topics still have all required fields
foreach (array('sort','label') as $f) { foreach (array('sort','label') as $f) {
if (isset($_POST["$f-$id"])) { if (isset($_POST["prop-$f-$id"])) {
$field->set($f, $_POST["$f-$id"]); $field->set($f, $_POST["prop-$f-$id"]);
} }
} }
if (in_array($field->get('name'), $names)) if (in_array($field->get('name'), $names))
...@@ -133,7 +133,7 @@ if($_POST) { ...@@ -133,7 +133,7 @@ if($_POST) {
} }
if ($list) { if ($list) {
for ($i=0; isset($_POST["sort-new-$i"]); $i++) { for ($i=0; isset($_POST["prop-sort-new-$i"]); $i++) {
if (!$_POST["value-new-$i"]) if (!$_POST["value-new-$i"])
continue; continue;
$item = DynamicListItem::create(array( $item = DynamicListItem::create(array(
...@@ -149,13 +149,14 @@ if($_POST) { ...@@ -149,13 +149,14 @@ if($_POST) {
} }
if ($form) { if ($form) {
for ($i=0; isset($_POST["sort-new-$i"]); $i++) { for ($i=0; isset($_POST["prop-sort-new-$i"]); $i++) {
if (!$_POST["label-new-$i"]) if (!$_POST["prop-label-new-$i"])
continue; continue;
$field = DynamicFormField::create(array( $field = DynamicFormField::create(array(
'form_id'=>$form->get('id'), 'form_id'=>$form->get('id'),
'sort'=>$_POST["sort-new-$i"] ? $_POST["sort-new-$i"] : ++$max_sort, 'sort'=>$_POST["prop-sort-new-$i"]
'label'=>$_POST["label-new-$i"], ? $_POST["prop-sort-new-$i"] : ++$max_sort,
'label'=>$_POST["prop-label-new-$i"],
'type'=>$_POST["type-new-$i"], 'type'=>$_POST["type-new-$i"],
'name'=>$_POST["name-new-$i"], 'name'=>$_POST["name-new-$i"],
)); ));
......
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