2sxc - Calculated Fields implementation - 2sxc

Can I make calculated fields in 2sxc?
Something like url path, but to use more fields and some additional logic?
Is the only way to do this custom property editor?
I also know for this video about url-path:
http://2sxc.org/en/Docs/Feature/feature/8305
But don't know where are sources for this editor that I can copy it and modify for my needs.

You would need to create a custom input type - see http://2sxc.org/en/Blog/post/custom-input-type-advanced-dynamic-data
the code for the url-path is here: https://github.com/2sic/eav-ui/blob/master/src/edit/fields/string/string-url-path.js

Related

Django Rest Framework render_form & required fields

When using HTML form renderer in DRF, can anyone think of a nice way to auto generate some indication of "required" field in DRF, by hook or crook? I mean before I submit the form, some indication on the field that it is required - the Browsable API it will show right in the form what the error is but only after submitting.
Whether I am using technique as shown here for browseable API with field level HTML forms (instead of just raw/JSON form):
django-rest-framework - autogenerate form in browsable API?
Or I am using TemplateHTMLRenderer with a call to render_form as discussed in docs here:
http://www.django-rest-framework.org/topics/html-and-forms/#rendering-forms
I don't see a simple way to make my required fields rendered as required. So say we have like
#models.py
class Foobar(model.Models):
foo = models.CharField(max_length=100, blank=True, default='')
bar = models.CharField(max_length=100, blank=False)
The best I can think of is making my own template/snippet for each type of field "required-text-field.html", "required-checkbox.html", etc and using the style declaration in the serializer as shown here:
http://www.django-rest-framework.org/topics/html-and-forms/#field-styles
That's assuming I am understanding this, have not played with it yet to see.
But I would love to see a way to auto-generate the field with/without a required flag as appropriate (even just an asterisk, or applying a CSS class) based on the model definition.
Rambling: The goal here was to avoid writing my own forms, having DRF generate the form for me in custom views. As opposed to writing my own forms using tying them into AJAX I figured templates, render_form, and some format checks would suffice. But now I'm thinking DRF is built for back-end and dev, not front-end, and maybe I should plan to write my own forms if it will be end-user visible? Also I could have CSS files and select based on name, calling render_form then applying hand spun styles, would be less work than the HTML + the CSS. Should I review Django (just Django, not DRF) Forms and re-use serializer as validation?...
I can see 2 ways:
you can define your own template pack, look at the existing ones in the sources (e.g. 'rest_framework/horizontal/input.html') - you can check if field is required and according to this flag, set some css. you do not need something extra, especially "input-readonly.html" - just make your own copy of input.html, add few if-s and it will work.
or you can call OPTIONS on the API endpoint to get all the necessary information about fields, not only required, but readonly and allowed values for some selects - this is if you can update your forms from javascript

Registering an HTML-derived content type with the HTML editor without a package?

I'm trying to register a custom content type, similar to this question on MSDN forums: I want to register a custom extension that is essentially an HTML file, e.g.:
[Export]
[DisplayName("My Custom Markup")]
[Name("mycustom")
[BaseDefinition("html")]
internal static ContentTypeDefinition MyCustomContentType;
[Export]
[FileExtension(".mycustom")]
[ContentType("mycustom")]
internal static FileExtensionToContentTypeDefinition MyCustomFileExtensionDefinition;
So by specifying BaseDefinition as html, I am able to get HTML highlighting in .mycustom files, unfortunately I get nothing else, in particular, the HTML intellisense. From the above link it seems that the only way to have Visual Studio recognize custom extensions as a specific editor type, but I'd have to hack the registry (or more specifically, provide this via the ProvideEditorExtension attribute, but it's only applicable on a VSPackage).
So my question is, basically, is there an alternative way to register a custom extension to an editor programmatically, but without creating a custom VSPackage for it? Other than hacking the registry, of course?
(I could be totally wrong with the approach, in which case your help is very much appreciated!)
The easiest way is to use the technique demoed here:
http://blogs.msdn.com/b/noahric/archive/2010/03/01/new-extension-css-is-less.aspx
This is effectively "hacking the registry" but in a supported way. You're simply wrapping the needed keys in a .pkgdef file (essentially a .reg file) that can be contained in an editor extension.

Enable tinyMce on all the nodes except one

node/*
user/*
comment/*
This is what I am using to enable tinyMCE Drupal on particular pages.
Now what I am looking for is to apply on all the NODES except the one having id (eg 100). How can I do that?
Use the WYISWYG API module and input formats.
Make an input format called Node100, which is a clone of the usual input format what you use for nodes. Do not enable TinyMCE on that input format. Set the input format for that node.
Take a look at this:
http://drupal.org/node/121331
It goes into depth on how to enable TinyMCE. I believe there is a Drupal admin setting for doing what you want.

Drupal views add form to add record

I have some view which lists my module table entries.
What is the most elegant way to attach a form below the view to add record?
Waht I am trying to do know is:
I created dedicated form in my module:
function my_module_form_add_record($form_state) {
form fields.....
}
I added to the view theme file:
$add_form = drupal_get_form('my_module_form_add_record');
print $add_form;
But I do not like this solution for at least 2 reasons:
I does not work ...
2. Even if it worked - it is depended on the theme file! So if I change the theme - functionality is crashed.
I would like to find more elegant solution to attach form from custom module to the view.
I know of the existence of the "Views Attach" module but it has no option of adding custom forms.
I know also of the existence of the Views Embedded form (and I am usig it) but it is only useful if you want to add form to the every row.
Seems the must be some solution to add record from the view page!
Thanks you for help.
you could use hook_views_pre_render:
This hook is called right before the render process. The query has been executed, and the pre_render() phase has already happened for handlers, so all data should be available.
Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after. Altering the content can be achieved by editing the items of $view->result.

Specifying edit paths in Drupal for FCKEditor?

With the FCKEditor, you can specifiy paths where the editor must be included. Eg.
node/add/email
Which works great, until you need to go back and EDIT that node. Which means you end at a path like so:
node/284/edit
Now, the fck editor no longer works, because the path isn't valid.
Is there any way that one can get the FCKEditor to work for both the normal path and the edit path of ONE SPECIFIC CONTENT TYPE?
I'm not sure if you can do this with stock the FCKEditor module. However, you can do it by using the WYSIWYG API module, which allows you to specify WYWIWYG editors on a per-input-filter basis, and Better Formats, which allows you to set input filter formats on a per-node-type basis.

Resources