Default value when using metadata xml forms.

Help us to improve OpenKM! Be part of the Open Source Community.
Forum rules
Please, before asking something see the documentation wiki or use the forum search function.
Post Reply
cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Default value when using metadata xml forms.

Post by cherifmad » Thu May 31, 2018 12:48 am

Good morning,
I have a problem.
I would like to know if it is possible to add a default value when we create an Xml metadata form.
for example :

Code: Select all

<property groups>>property groups
  property group label="Consulting" name="okg:consulting">"okg:consulting".
    <input label="Name" type="text" name="okp:consulting.name "value=" default name"/>" name"/>".
    <input label="Date" type="date" name="okp:consulting.date" value ="default text"/>>default text".
    <checkbox label="Important" name="okp:consulting.important"/>>".
    <textarea label="Comment" name="okp:consulting.comment" value=" textarea by default" />>"okp:consulting.comment" value=" textarea by default".
    <input label="Input label" name="okp:consulting.input1" />"Input label" name="okp:consulting.input1" />
    <separator label="Separator label" name="okp:consulting.separator" />"okp:consulting.separator" /> 
    <input label="Input label" name="okp:consulting.input2" />"Input label="Entrée label" name="okp:consulting.input2" />

    
  </group of goods>>group of goods
I'm trying but there's an error on my screen:

Application error
Class: com.openkm.core.ParseException
Message: Attribute "value" must be declared for element type "input".
Date: Thu May 31 00:46:12 UTC 2018

can you help to resolve it.
thanks for all

lnovoa
Expert Boarder
Expert Boarder
Posts: 119
Joined: Tue Mar 27, 2018 8:00 am

Re: Default value when using metadata xml forms.

Post by lnovoa » Thu May 31, 2018 3:27 pm

Hi!,
The xml was not well formed, if it is as you show in the post.
Try this example and you will see the default values.

https://docs.openkm.com/kcenter/view/ok ... field.html

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.9//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.9.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <input label="Name" type="text" name="okp:consulting.name" value="default value"/>
      <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
       <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
        </property-group>
</property-groups>

cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Default value when using metadata xml forms.

Post by cherifmad » Thu May 31, 2018 4:11 pm

lnovoa wrote:
Thu May 31, 2018 3:27 pm
Hi!,
The xml was not well formed, if it is as you show in the post.
Try this example and you will see the default values.

https://docs.openkm.com/kcenter/view/ok ... field.html

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.9//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.9.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <input label="Name" type="text" name="okp:consulting.name" value="default value"/>
      <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
       <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
        </property-group>
</property-groups>
Thanks Dear Inovoa, I have try it ( your script) But this error appear ...
how can I resolve and fix this problem
Attachments
erreur 2.png
erreur 1.png

lnovoa
Expert Boarder
Expert Boarder
Posts: 119
Joined: Tue Mar 27, 2018 8:00 am

Re: Default value when using metadata xml forms.

Post by lnovoa » Fri Jun 01, 2018 8:09 am

Hi,
In this link, you can see how it is built and then you simply have to add
the value properties and the date format mentioned in the previous post

https://docs.openkm.com/kcenter/view/ok ... ition.html

cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Default value when using metadata xml forms.

Post by cherifmad » Fri Jun 01, 2018 9:37 am

lnovoa wrote:
Fri Jun 01, 2018 8:09 am
Hi,
In this link, you can see how it is built and then you simply have to add
the value properties and the date format mentioned in the previous post

https://docs.openkm.com/kcenter/view/ok ... ition.html
I saw this link again, I set the default value, but the same error persists.
Please, can you write a script that works very well in your openKM and I will test at home to see where I make my mistakes?
thank you for your understanding

lnovoa
Expert Boarder
Expert Boarder
Posts: 119
Joined: Tue Mar 27, 2018 8:00 am

Re: Default value when using metadata xml forms.

Post by lnovoa » Fri Jun 01, 2018 11:23 am

Hi!,

for example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.7.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
    <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
   </property-group>
</property-groups>

cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Default value when using metadata xml forms.

Post by cherifmad » Sat Jun 02, 2018 1:07 am

lnovoa wrote:
Fri Jun 01, 2018 11:23 am
Hi!,

for example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.7//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.7.dtd">
<property-groups> 
  <property-group label="Consulting" name="okg:consulting">
    <checkbox label="Important" name="okp:consulting.important"/>
    <textarea label="Comment" name="okp:consulting.comment" value="textarea by default" />
    <input label="Input label" name="okp:consulting.input1"  value="default value" />
    <separator label="Separator label" name="okp:consulting.separator" />
    <input label="Input label" name="okp:consulting.input2" value="default value" />
    <input label="Date" type="date" name="okp:consulting.name" value="20100611221912"/>
   </property-group>
</property-groups>
Sorry, I have executed your Script but an over error appear ... See the screenshot
Thanks for your understanding
Attachments
erreur 2.png
erreur 1.png

jllort
Moderator
Moderator
Posts: 10907
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Default value when using metadata xml forms.

Post by jllort » Sat Jun 02, 2018 4:35 pm

Community DTD latest version is 2.3 not 2.7 as you can see here https://docs.openkm.com/kcenter/view/ok ... table.html

Try with:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.3//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.3.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <input label="Input label"  name="okp:consulting.input" value="test" />
  </property-group>
</property-groups>

sonnysiah
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: Wed Jul 17, 2019 6:57 am

Re: Default value when using metadata xml forms.

Post by sonnysiah » Wed Oct 23, 2019 6:13 am

1.png
1.png (2.85 KiB) Viewed 576 times
Hi,

I also have the similar question but it apply to Date field, I need have auto set the current date instead of preset value, is it possible?

I have read the article and also changed the header DTD ver from default 2.0 to 2.9 and the test on preset value work. My OpenKM is 6.3.8 CE running on Windows

extract setting from my test openkm metadata

Code: Select all

</select>
    <input label="DATE CREATED" type="date" name="okp:group.date" value="20191023153000" />     	
    <input label="SUBJECT" name="okp:group.subject" width="200px"/>
    <textarea label="DESCRIPTION" name="okp:group.description"/>
    <input label="CREATED BY" name="okp:group.createdby"/>  
    <input label="LAST VIEW BY" name="okp:group.lastviewby"/>  
  </property-group>

jllort
Moderator
Moderator
Posts: 10907
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Default value when using metadata xml forms.

Post by jllort » Sat Oct 26, 2019 9:21 am

Currently is not possible to preset the current date, should be modified the source code for it. In this scenario the property group should be going into something like a filter for updating the default value before you getting from the API, basically, I'm talking about a second step in the process of getting the metadata form values.

If you wish I can try to give you some clues about in what direction the code should be modified.

Post Reply