Commit e84be83e546fc4e53715aa09e64066eb445669f4
1 parent
e66be5e2
Enable required metadata
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5501 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
17 additions
and
2 deletions
plugins/ktcore/admin/documentFields.php
| ... | ... | @@ -106,7 +106,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { |
| 106 | 106 | $createFields = array(); |
| 107 | 107 | $createFields[] = new KTStringWidget(_kt('Name'), _kt('A human-readable name, used in add and edit forms.'), 'name',null, $this->oPage, true); |
| 108 | 108 | $createFields[] = new KTTextWidget(_kt('Description'), _kt('A brief description of the information stored in this field.'), 'description', null, $this->oPage, true); |
| 109 | - | |
| 109 | + $createFields[] = new KTCheckboxWidget(_kt('Required'), _kt('Are the values in this field required?'), 'is_required', false, $this->oPage, false); | |
| 110 | 110 | |
| 111 | 111 | // type is a little more complex. |
| 112 | 112 | $vocab = array(); |
| ... | ... | @@ -220,7 +220,9 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { |
| 220 | 220 | $aErrorOptions = array( |
| 221 | 221 | 'redirect_to' => array('edit', sprintf('fFieldsetId=%d', $oFieldset->getId())), |
| 222 | 222 | ); |
| 223 | - | |
| 223 | + | |
| 224 | + $is_required = KTUtil::arrayGet($_REQUEST, 'is_required', false); | |
| 225 | + if (empty($is_required)) { $is_required = false; } | |
| 224 | 226 | $is_lookup = false; |
| 225 | 227 | $is_tree = false; |
| 226 | 228 | if ($_REQUEST['type'] === "lookup") { |
| ... | ... | @@ -247,6 +249,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { |
| 247 | 249 | 'haslookup' => $is_lookup, |
| 248 | 250 | 'haslookuptree' => $is_tree, |
| 249 | 251 | 'parentfieldset' => $oFieldset->getId(), |
| 252 | + 'ismandatory' => $is_required, | |
| 250 | 253 | )); |
| 251 | 254 | if (PEAR::isError($res) || ($res === false)) { |
| 252 | 255 | $this->errorRedirectTo('edit', _kt('Could not create field') . ': '.$_REQUEST['name'], 'fFieldsetId=' . $oFieldset->getId()); |
| ... | ... | @@ -313,6 +316,13 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { |
| 313 | 316 | |
| 314 | 317 | $oField->setName($_REQUEST['name']); |
| 315 | 318 | $oField->setDescription($sDescription); |
| 319 | + $is_required = KTUtil::arrayGet($_REQUEST, 'is_required', false); | |
| 320 | + | |
| 321 | + if (!$is_required) { $is_required = false; } | |
| 322 | + else { $is_required = true; } | |
| 323 | + | |
| 324 | + $oField->setIsMandatory($is_required); | |
| 325 | + | |
| 316 | 326 | $res = $oField->update(); |
| 317 | 327 | if (PEAR::isError($res) || ($res === false)) { |
| 318 | 328 | $this->errorRedirectTo('editField', _kt('Could not save field changes'), 'fFieldsetId=' . $oFieldset->getId() . '&fFieldId=' . $oField->getId()); | ... | ... |
templates/ktcore/metadata/editField.smarty
| ... | ... | @@ -19,6 +19,11 @@ |
| 19 | 19 | <th>{i18n}Type{/i18n}</th> |
| 20 | 20 | <td>{$oField->getType()|escape}</td> |
| 21 | 21 | </tr> |
| 22 | + <tr> | |
| 23 | + <th>{i18n}Required{/i18n}</th> | |
| 24 | + <td><input type="checkbox" name="is_required" {if ($oField->getIsMandatory())}checked="true"{/if} /></td> | |
| 25 | + </tr> | |
| 26 | + | |
| 22 | 27 | </table> |
| 23 | 28 | |
| 24 | 29 | <div class="form_actions"> | ... | ... |