McNull / angular-form-gen

Design Bootstrap based form schemas for AngularJS in a drag and drop WYSIWYG environment.
MIT License
135 stars 81 forks source link

Making the Field Name a dropdown or readonly #18

Closed runnerman261 closed 8 years ago

runnerman261 commented 8 years ago

Wondering if there is a way to make the Field -> Name in the designer field properties a dropdown that can be populated with a predefined list of fields in a database table or make at the least make it readonly?

mmaask commented 8 years ago

Very vague description for me, could you explain a bit in more detail?

runnerman261 commented 8 years ago

Here is what we are trying to do - We want to use the form designer to allow users to design a form based on a database schema. Assume the DB has the following fields "Text1", "Text2", "Text3", "Number1", "Number2", "Number3". When i drag and drop a text field into the canvas and go to Configure ->Properties, i would like to make the "Name" property a dropdown that shows Text2, Text2, Text3. This way we clearly know which field in the DB the text field maps to.

Here is a screen shot of how it would work image Hope this clarifies the question. Thank you for taking the time to respond.

mmaask commented 8 years ago

I really don't see point in doing that. You couple your database to the internal structure of the form. There actually shouldn't even be the name field at all, it should be hidden and the value stored as random values because it is only used internally thus there is no reason to change it at all.

I have hidden name field for my text fields and radio/checkbox options all together, if you are not the only one using the application and someone decides to change the internal name on some form that already has records then you're gonna have a bad day.

runnerman261 commented 8 years ago

Ok, thanks for the suggestion. I could couple the db to the internal structure of the form. Since i could not find any direct documentation on hiding the "name" field, how would i hide it from the user when the click on the "configure" button.

mmaask commented 8 years ago

You would have to fork/clone the repository, edit the code and build new distribution package. This project has one of the best written codes I have ever seen. It can be extended so easily as I've added many new field templates myself and done changes to my needs.

To do that you would need to edit the particular template file under 'field-templates' directory. For regular text field it is https://github.com/McNull/angular-form-gen/blob/master/src/angular-form-gen/field-templates/properties/text.ng.html -- here you simply would have to remove fieldname: true from the object and you're good to go :)

runnerman261 commented 8 years ago

Thank you very much for taking the time to respond to my question.