Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add list of preconfigured fields #17

Open
gentledepp opened this issue Dec 13, 2015 · 3 comments
Open

Allow to add list of preconfigured fields #17

gentledepp opened this issue Dec 13, 2015 · 3 comments

Comments

@gentledepp
Copy link

Hi!

First of all - this form generator looks great.
However, in order to be able to use it, we need to be able to specify our own list of fields and those fields are preconfigured and can only be added but not changed.

The reason behind this, that we have an application that allows to add additional fields to existing entities.
Say we have a task with the fields "AssignedUser, Title, DueDate" and then the user adds a custom field "Category"
This category field is defined elsewhere in our application as an enumeration of categories.
So basically, the user should now be able to place the field on the form and edit some of its visual properties like being displayed as a dropdown or a radio button list.

Moreover, we'd like to disable all of your barebone fields.

Would that be possible?

@MacKentoch
Copy link
Owner

Hi @gentledepp,

Thank you for your nice feedback.

If I correctly sum up your request (feel free to correct me if I'm wrong), it would be nice to :

1- preload existing form

  • already possible with :
//easy form generator :
<eda-step-way-easy-form-gen     
      eda-easy-form-generator-model="_MODEL_"
      eda-save-form-event="_SAVE_FUNCTION_">
</eda-step-way-easy-form-gen>
  • and pure static (I mean not editable) form :
//easy form viewer = just render a form : 
<eda-easy-form-viewer
        eda-easy-form-viewer-data-model="demoCtrl.dataModel"
        eda-easy-form-viewer-easy-form-generator-fields-model="demoCtrl.fieldsModel"

        eda-easy-form-viewer-submit-button-text="{{demoCtrl.submitButtonText}}"
        eda-easy-form-viewer-cancel-button-text="{{demoCtrl.cancelButtonText}}"

        eda-easy-form-viewer-submit-form-event="demoCtrl.submitFormEvent(dataModelSubmitted)"
        eda-easy-form-viewer-cancel-form-event="demoCtrl.cancelFormEvent()">    
</eda-easy-form-viewer>

2- but loaded form should have locked fields

  • that is a really nice feature.

But right now it is not implemented...

BUT it may not be that hard to satisfy your needs since it seems like it is just a matter of new custom formly control

A control is basically some kind directive and you can create unlimited custom formly controls.
An exemple : here.

    // here is this custom formly multi input control (JS part) :
    formlyConfigProvider.setType({
      name: 'multiInput',
      templateUrl: 'multiInput.html', //I don't copy html but you check the template in JSBIN in the upper link 
      defaultOptions: {
        noFormControl: true,
        wrapper: ['bootstrapLabel', 'bootstrapHasError'],
        templateOptions: {
          inputOptions: {
            wrapper: null
          }
        }
      },
      controller: /* @ngInject */ function($scope) {
        $scope.copyItemOptions = copyItemOptions;

        function copyItemOptions() {
          return angular.copy($scope.to.inputOptions);
        }
      }
    });

I would have to add this new template to easy form generator if it were exactly the one you needed.

Now the most difficult part may be to :

  • clearly define the need (to be sure to understand what control should be created)
  • or you create on your own custom formly controls if you feel ok with formly. Then I integrate them all in easy form generator, like that even easy form viewer would have editable controls.

How does it sound like for you? It would be nice I think.

@gentledepp
Copy link
Author

Hey, thanks for the quick response!

But basically the answer is "no, this is not what I meant" - I apologize.

Your angular module basically provides a way to create complete forms that consist of

  • fields (including validation and display logic)
  • and layout.

In our case, fields are defined separately. You can think of it like a CMS.
You have some built-in content types that consist of a set of fields. Those fields cannot be removed from their content types, but you can add additional fields.
As an example, you can look at the documentation of Orchard CMS:
http://docs.orchardproject.net/Documentation/Creating-custom-content-types

So basically the user has the ability to add additional custom fields to one of the predefined content types.
Those fields define their data type, their default display type, their validation logic, etc.)

Now we need to somehow give the user the ability to add those self-created fields to the existing built in content types forms.

So what we'd basically like to do is to provide your form generator with a an array of field objects that are already completely configured (those can be angular-formly fields)
The user can now only

  • modify fhe layout of the form (such as placing the newly created field somewhere)
  • add validation and presentation logic

As this is merely a reduction of functionality (i.e. locked-down field definitions) I hoped it would be quite easy to implement. :-|

Tell me what you think!

@MacKentoch
Copy link
Owner

Sorry for my misunderstanding.

Don't worry and let me think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants