Copying Form controls and Name property

Issues related to forms.
Post Reply
WWBman
 
 
Posts: 867
Joined: Fri Jan 08, 2010 6:10 pm

Copying Form controls and Name property

Post by WWBman » Tue Sep 22, 2020 1:33 pm

When copying and pasting a form control that has a Name property e.g. Editbox and TextArea the newly created control retains the same Name property instead of using the ID as the Name.

This shows in the email output but particularly in writing records to a MySQL database.
E.g. if you start with Editbox1 and copy it twice so creating Editbox2 and Editbox3 then 2 and 3 will each have a Name property of Editbox1.
The MySQL table will only have one data column with the name EDITBOX1 (from Editbox3 Name property) and contain the data from Editbox3.

User avatar
Pablo
 
Posts: 21820
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: Copying Form controls and Name property

Post by Pablo » Tue Sep 22, 2020 2:46 pm

This is intentional behavior. Normally, a form has meaningful field names, like name, email, phone etc.
If you copy/paste this form to another page or project then in most cases you want to keep these names.

WWBman
 
 
Posts: 867
Joined: Fri Jan 08, 2010 6:10 pm

Re: Copying Form controls and Name property

Post by WWBman » Tue Sep 22, 2020 3:11 pm

If copying the form to another page then I agree you want to keep the names.
But copying and pasting e.g. editboxes in the same page and form surely should set Name the same as the ID to be consistent.

User avatar
Pablo
 
Posts: 21820
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: Copying Form controls and Name property

Post by Pablo » Tue Sep 22, 2020 3:19 pm

Unfortunately, there is no way to detect if the object was copied from the current page or from another page.
On the Windows clipboard then is no 'context' information.

WWBman
 
 
Posts: 867
Joined: Fri Jan 08, 2010 6:10 pm

Re: Copying Form controls and Name property

Post by WWBman » Tue Sep 22, 2020 3:39 pm

I see, OK thanks.

Post Reply