"Import" forms from other apps

I’d like to be able to take “things” (forms/modules/etc.) and import them into a project.

Unlike adding a dependency, the imported thing would be a local copy, meaning you can modify it without altering the source.

I’m sure I could achieve something similar with git, but git scares a lot of people (including me). A built in “safe” way would be great.

Maybe something like an Anvil “clipboard” - copy the form into it, then paste into your new project.

3 Likes

How is this different from cloning an app?

1 Like

You clone an entire app.

I want to be able to import (say) the clients form & associated code from one app, the stats code from another, etc. Basically, cherry picking.

You can do it, but it’s outside of the IDE and can be a little fraught for people like me. I’d just like it all within the environment.

I don’t expect I’ll get it :slight_smile:

Hi David,

A system to copy Form code and design between apps in the IDE would definitely be a good improvement.

Regarding doing it in the Git repo, there’s no black magic, you just need to copy the Form code and config file over.

Let’s say you want to copy Form2 from one app to another, you would do this:

  • Clone both apps
  • Copy Form2.py and Form2.yaml from source app to target app’s forms directory
  • make a commit in the target app’s repo (git commit -a -m 'copy Form2')
  • push target app to Anvil (git push)

All you need is the .py file and the .yaml file for your app - there’s no hidden config elsewhere.

Just a wee bit of forethought may be in order. Both the .yaml and the .py file may contain dependencies.

The .py file may contain import statements. You’ll want to make sure that these are satisfied in the new location. That is, if the corresponding files are not already there, then you’ll want to copy them.

Likewise, the .yaml file may use other Forms as components. If it does, then you’ll need to make sure that they’re satisfied, too, in the same manner.

If you do end up copying any files, also check them for dependencies, in the same manner.

1 Like