need recomandation to create forms in drupal 8 - drupal-8

I want to have 4 different forms in Drupal 8 with each form will have an approximate 250 - 300 fields.
There will be a huge data (count)
Now what module / approach I choose in Drupal 8?

You can crate a custom form:
https://www.drupal.org/docs/drupal-apis/form-api/introduction-to-form-api
Or you can use webform module. If you going to use webform module with that many fields I recommend createing all the fields with yml builder (via UI) because it will be faster.
Decision what is better in your example is based on your coding skills (webforms are easier), how many reusable components you need (reusable componnents could be managed easier programatically - custom form) and if you see an option that you can make all fields programatically with an ease.

Related

Do I need to create forms.py for my forms in Django?

I'm about to create a form in my website made in Django with elements that have complex input types from different plugins (like calendar plugins). Also, I'll be using a Validator plugin which validates the input before submission.
My question is do I need to create forms.py and like model the form or can I just create the form manually? The former seems like a very hassle process. Which one is more efficient and recommended?
As #dmitryro said you can create your forms manually in the templates and then getting in the request. It's recommended to use the forms api provided by Django since it allows you to reuse, validate, and customize your forms.
As to whether or not it is a good practice that depends completely on you but if you are trying to scale an application I would recommend use the forms.
It is good to use Django's built in form.
If we use django's form then we only have to write python code and django will create corresponding html for it. And our code will be short and clean.

Writing translatable static web pages using Django

I am a bit confused on the best way to handle this problem:
My web site needs read-only static web pages (typically the About part of a web site) with 2 simple constraints:
they need to be translated
they need to have flexible layout: to incorporate base headers/footers, floating images and/or tables, and non-interactive elements (like a bootstrap carousel).
Several solutions that I have thought about:
I can of course directly write HTML files but the translation part will be awkward (a lot of <h1>, <ul>, <li> and <p> which are of no interest to the translator).
I can use Django flatpages with some markup languages but I lose a lot of flexibility (for instance template tags are not recognized)
Use generators like Hyde, but it seems quite overkill for my needs and internationalization seems a bit difficult
Does someone have other propositions that I can look into ?
Thanks !
Use django-cms, it has a Page model that can be translated and has a very smart plugin system to add many content-types into every page.
I use it a lot and it's very easy and yet powerful
For completeness and fairness, here's a full list of available CMS packages for Django.
for a much simpler solution, I would create a model called "Page" with lets say title and text fields.
The title and the text fields I would register to django-modeltranslation which will handle the translation issue.
For the text field i would use TinyMCE which let you insert basically any HTML you want so you can do whatever you need.

Sitecore WebFoms for Marketers module

I want to ask you how it will be better to implement: using Sitecore WebForms for Marketers module or in standard .ascx sublayout.
So I need to implement huge form with dynamic dropdowns, date pickers, checkboxes, radiobuttons, etc. This form contains also dynamic adding new controls (see description in attachment above). So is it possible to create this form in Sitecore WebForms for Marketers module or it will be easier to write it as standard form in ascx.
This form will be saved to sitecore database.
Please answer if somebody have already done smth like this.
Thanks.
To my kowledge it isn't possible to do this out of the box with WFFM in Sitecore.
I guess the first question to ask is: do you or your customer want/need to be able to manage forms themselves without developer interaction?
If the answer to this question is yes, then you could try to implement this with WFFM, otherwise it may be easier to just implement as a normal sublayout.
EDIT
One other thing you could also do is to create a form, then use the 'export to ascx' function. You can look at the generated code to see how the data is written to the WFFM database - this way you can have your custom form functionality but still leverage the reporting functionality in the Sitecore client. If you have some decision tree-like logic for displaying the different fields you could probably drive this from Sitecore content items as well.
As per my knowledge you can create this form with the help of Web form for marketer but in this case you need to create some custom fields and update these fields as per your requirement.
To Create custom field create field under /sitecore/system/Modules/Web Forms for Marketers/Settings/Field Types/Custom location and in custom field define your created custom class and assembly.
You can update design by applying your custom css classes.
Class you can create under /sitecore/system/Modules/Web Forms for Marketers/Settings/Meta data/Css Classes location and apply class on specific control.

django==1.4 support for html5

I have a small blog app I have built using Django 1.4 and recently, I have been learning "bits and pieces" of html5 and css3. I am about the start transitioning my site to html5/css3 and I was wondering if Django widgets support html5(?)
My blog is nothing special - a few forms, a few tables etc.. For example when I do,
{{form_as_p}}
I was wondering if django would generate the required html5 markup(?) I read the docs, and it says the admin pages support html5, but I could not find any docs for regular apps.
If html5 is not supported by Django, what is the best way going about achieving this?
Thanks for your time.
Django's form output is XHTML. Django does not snip with support for the new HTML5 input types such as number, email, url, etc but it is not difficult to add them. See https://code.djangoproject.com/ticket/16630 or https://github.com/rhec/django-html5 That being said I don't know any place where Django generates markup that is invalid for HTML5.
"If html5 is not supported by Django, what is the best way going about achieving this?"
I have been trying a monkeypatch approach with very encouraging results so far, the big bonus for me is that there is no need to change your existing code, or for modifying third party apps, or Django admin. This keeps things very clean and central and there is no need for hairy and repetitive admin.site.register(...)/admin.site.register(...).
https://github.com/danielsokolowski/django-html5monkeypatch

Editable unstructured pages

I'm building a small site framework for a set of sites that are likely to have quite a few unstructured pages - meaning they have:
Slightly different layouts per page
Lots of one-off text
None/very little generated content from models
I would like to allow clients to edit the content of these pages through my admin UI (I'm using Django for this project), but with the requirement that they are not exposed to the page HTML and are only able to edit parts of the page that I've specified as fields; for example:
Titles
A few blocks of text content
Perhaps some blocks of predefined image locations
PDF files that need embedding
Where these fields vary significantly between pages.
The layout, and what fields these pages require would be specified by the developer, so there's no need to dynamically generate much for this.
The 'best' idea I've had so far is to serialise these blocks of content once they've been edited by the user and store them in a 'Pages' table/model in my relational database, or just throw MongoDB or similar at it.
Conceptually, how would you implement such pages? As mentioned, I'm using Django so any implementation suggestions specific to Django are welcome, but general high-level ideas would be great too.
I would implement a ContentBlock model, which has .kind (header, text, image, pdf) and a .data, which would house the content (if text) or path to an uploaded pdf/image/etc. Presumably then you'd hardcode the pages with the appropriate blocks defined - I'd just use hardcoded slugs, eg, 'home-title', 'home-intro', 'about-title', 'about-text', 'about-right-photo', etc.
I would suggest not using Django's admin interface. It's much more suited to editing homogenous, non-business-logic models. I'd just add an edit view that renders the appropriate form fields for the blocks instead - html editor, file upload, etc. It's possible to do that in the django admin, but in my experience it's not worth the trouble - plus, if you do your own edit view, you can have it use the same base templates as the rest of the site, which IMO is a better user experience.
Here are a couple of apps which do that for you:
django-generic-flatblocks
django-boxes
Along with django-frontendadmin, it's super cool.