Thank you for answering my previous questions and I appreciate the effort put in by you in developing Moqui.
In the field tag there is an attribute of validate-parameter so could please elaborate the use of it and how to use that attribute. Thanks in advance :-)
To be specific, it sounds like you are looking at the XML Form field element (form-list.field, form-single.field).
A form field can be validated based on the validation settings in a service parameter (there are many validation options there) or an entity field (just a couple validation options there). This is done automatically when a form submits to a transition that has a single service-call element (i.e. not an actions element), and these attributes are populated automatically. You can also specify manually which service/parameter or entity/field to use for validation.
This is all part of the support in the framework to do client side validation with JavaScript using server-side validation settings. Note that the validations are also done on the server, but you don't have to define/implement them twice.
Related
I wonder how to make some fields of an entity extension searchable in the administration through the "/api/search/my-entity" api-endpoint. By default they are not considered during search as it looks like.
I found the answer by debugging the search-endpoint:
The association-Field of the EntityExtension needs to have a SearchRanking-flag:
...->addFlags(new SearchRanking(SearchRanking::ASSOCIATION_SEARCH_RANKING))
Then you can add SearchRanking-flags in the EntityExtensionDefinition as you like, e.g.:
(new StringField('test', 'test'))->addFlags(new SearchRanking(SearchRanking::HIGH_SEARCH_RANKING)),
After that the fields are searchable via the search-endpoint :)
As far as the API is concerned, search functionality should automatically be generated following your custom entity definitions.
When it comes to facilitate Admin search for your entity, you need to add some code to the administration component as described in the docs: https://developer.shopware.com/docs/guides/plugins/plugins/administration/search-custom-data (even though it looks not fully up-to-date w.r.t to the current Shopware versions).
I am trying to create some dynamic forms using Piranha CMS. As far as I managed to learn it is not supported right now, so I'm looking for work arounds or alternatives.
What I want to do now is use the editor from the manager for other users. To be more precise: this is how the editor looks like inside my manager when I want to edit a page
I have a text input and a select, both are Fields and there are many more fields to be used.
I want the sys admin to create a page with a list of inputs like this, which right now are usable only by the admin. BUT make this list of inputs available for edit to other users as well. Is it possible?
I'm not sure how to extract this editor or behavior or even if it is possible. The problem is we really need the admin to be able to configure different form inputs for users as it is the main core of our functionality.
Any help/advice is highly appreciated, thank you!
The components in the management UI is not designed to be reused in the front-end application in any way. The edit models in the manager contains a lot of extra meta data since the UI is completely generic. If you want to build an edit UI in your front end application, and you're using MVC or Razor Pages, the simplest way is to.
Get the generic model instead of your strongly typed model, for example api.Pages.GetById(...) instead of api.Pages.GetById<T>(...).
Loop the available fields in your selected region (a region is an ExpandObject which can be casted to an IDictionary<string, object>).
Use the built in support in Razor by calling #Html.EditorFor(...) for the fields.
Using this approach you can easily create your own EditorTemplates for the different types of fields you use that will match the rendering in your client application.
Best regards
HÃ¥kan
If one has to perform business rules related validations and some cross field validations; on data entered in html-form-fields on screen, how can it be done?
Does the Moqui framework provide any inbuilt-support for this?
Is there any guide/tutorial available for this?
Update:
Hi David, thanks for your time. Below is the detailed requirement for validation.
1) Need to show the validation message on submit (before the request is sent to server) rather than after the request is processed on server.
e.g. When I open a dialog/screen to create/update some record, than I pass invalid number(e.g. 'abc') value in field and click submit;
the FORM gets submitted and the response (on next screen) is:
The value [abc] is not valid for type [java.lang.Long] (for field xyz) etc.
So, how can the FORM-submission be prevented and how to show message to user before submitting and on the same screen not on next screen? (ie.
how to implement validation similar to javascript validation at field/FORM-submit level). And this may be required not only on
just one screen but on many other screens may have thier own screen specific different validation rules for various fields.
Traditional way of adding bunch of .js files in header/footer doesn't look right; because how all the FORMs would know(without making
some changes to how the FORM gets generated) which js-function to invoke and when? And also I don't want to make any custom change in
framework which may not be compliant with any future upgrade of moqui or may require lot of re-work to integrate it smoothlessly for future upgrades.
2) Cross field validation i.e. filed1 is to be validated based on result of some calculation of values in field2 and/or field3 etc. How can this
be done on client-side?
I'm relatively experienced with Angular having written many directives, but I have a new requirement where I have to build a query-by-example form into which a user can enter different search criteria. My problem is that I do not know ahead of time what the possible criteria will be. This criteria information will be coming from the server via an ajax request and can differ per user. Thus I will need to dynamically construct a suitable user interface based on the information I get from the server.
I have built individual directives suitable for capturing the search criteria (for example a custom calendar control for date criteria) but I am unsure of the best approach to adding these directives to a form dynamically. Is this even possible in Angular?
I have built something like this before in jQuery but its not so clear to me how I would best do this in an 'Angular way'?
Any suggestions would be most appreciated!
Everything that you can express as a model-to-view projection can be implemented in AngularJS.
I think here you can make a model consisting of "query params". Each of them has name, type and data for filter builder. For example, for the "select" type a data can contain a list of all possible values to choose from.
Then you iterate through the list of "query params" with ng-repeat, rendering each control differently according to its type. That's all.
If I understood the task wrong, please provide more info.
I need to validate user email input from the site. Of course there is django.core.validation. However is not it easier to just use jquery validation plugin without sending POST data before all fields are valid? Or it is just better to validate threw views? Why?
This is a design decision that you can choose to make. If you need the real-time validation of your fields, then jquery-validation is the way to go.
However, if you want the validation to be done on a postback, you'll be better off using Django's form validation to get the job done.
If you do decide to do the validation on the postback, all of you have to do is use the EmailField and django will take care of the rest.