# Issue with Dynamic Calendar Field

**URL:** <https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058>\
**Category:** Classic Servoy\
**Created:** [April 16, 2010, 2:06am UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058 "2010-04-16T02:06:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![madimane](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@madimane](https://forum.servoy.com/u/madimane)\
**Post date:** [April 16, 2010, 2:06am UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/1 "2010-04-16T02:06:56Z")

</div>

Hi all,  
Thanks for all Servoy community who are doing a great job.  
I want to share with you a problem I encountered with Calendar field,especially its format property.

I created a form with a solution form (based on an empty static form with no datasource).  
I have to add fields dynamically witch can in every type (TEXT\_FIELD,CHECK,CALENDAR…).  
When I create a CALENDAR field, i set its format to “yyyy-MM-dd”.  
It works nice if I haven’t created in the form another field with another type,But if I created  
a field with another type the format is set to the default!!!

Here is a sample solution that illustrate the issue.

the check field in the main form indicate if true that you want to create a calendar field,else  
it’s a textfield.

to reproduce the issue, uncheck the checkbox and click the button,  
set the value,after that close the window,check the checkbox and click the button, the format is the default!  
even if I remove the form from the history and set the format.

Thank you for Any explanation of this behaviour.

[testCalendar.servoy](https://forum.servoy.com/uploads/short-url/flRkAXOBra5GPKdpQ79X5MhST5f.servoy) (6.05 KB)

---

<div class="post-metadata">

**Author:** ![lvostinar](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lvostinar/32/5248_2.png) [@lvostinar](https://forum.servoy.com/u/lvostinar)\
**Post date:** [April 16, 2010, 8:42am UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/2 "2010-04-16T08:42:44Z")

</div>

> madimane:  
> Hi all,  
> Thanks for all Servoy community who are doing a great job.  
> I want to share with you a problem I encountered with Calendar field,especially its format property.
> 
> I created a form with a solution form (based on an empty static form with no datasource).  
> I have to add fields dynamically witch can in every type (TEXT\_FIELD,CHECK,CALENDAR…).  
> When I create a CALENDAR field, i set its format to “yyyy-MM-dd”.  
> It works nice if I haven’t created in the form another field with another type,But if I created  
> a field with another type the format is set to the default!!!
> 
> Here is a sample solution that illustrate the issue.
> 
> the check field in the main form indicate if true that you want to create a calendar field,else  
> it’s a textfield.
> 
> to reproduce the issue, uncheck the checkbox and click the button,  
> set the value,after that close the window,check the checkbox and click the button, the format is the default!  
> even if I remove the form from the history and set the format.
> 
> Thank you for Any explanation of this behaviour.

Please add a case about this in our support system ([http://www.servoy.com/s](http://www.servoy.com/s)) . Why don’t you use a dynamic (solution model) frm2 ? Then it works if remove it from solution model (removeForm).

---

<div class="post-metadata">

**Author:** ![madimane](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@madimane](https://forum.servoy.com/u/madimane)\
**Post date:** [April 16, 2010, 1:57pm UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/3 "2010-04-16T13:57:54Z")

</div>

Thank you Ivostinar for your reply,  
I used the clone form method of solutionModel to make up for the issue.

```auto
if(solutionModel.getForm('frm2_child') != null)
{
	history.removeForm('frm2_child');
	solutionModel.removeForm('frm2_child');
}
var parentForm = solutionModel.getForm('frm2');
	
var frmResult = solutionModel.cloneForm('frm2_child',parentForm);
...

```

I’ll add a case for that.  
Thank you for your support ![:)]( "Smile")

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [April 28, 2010, 3:25pm UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/4 "2010-04-28T15:25:10Z")

</div>

The initial problem is related to changing the datasource for your form every time.  
We’ll have to find a way to avoid it.

---

<div class="post-metadata">

**Author:** ![madimane](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@madimane](https://forum.servoy.com/u/madimane)\
**Post date:** [April 28, 2010, 6:48pm UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/5 "2010-04-28T18:48:55Z")

</div>

Yes I agree.  
It would be very handy if we can change the datasource even if the form is used.

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [April 29, 2010, 3:52pm UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/6 "2010-04-29T15:52:41Z")

</div>

The problem is solved starting with 5.1.3; you will be able to use the code as it is in the sample solution.

Another way to do it is by calling “revertForm(…)” instead of “getForm(…)” and then you will have frm2 reverted to it’s initial state, no need to remove fields either.  
By using revert it will work with your current build and the rest of your current js as well.

---

<div class="post-metadata">

**Author:** ![madimane](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@madimane](https://forum.servoy.com/u/madimane)\
**Post date:** [April 30, 2010, 6:09pm UTC](https://forum.servoy.com/t/issue-with-dynamic-calendar-field/12058/7 "2010-04-30T18:09:04Z")

</div>

Thank you for your effort and your precision.
