Package: rt.zptformfield
This isn’t the form library you’re looking for95% you don’t need this package: try some real Plone form libraries like:z3c.formcollective.wtformsMove along… move along…Your mind powers will not work on me, boyIf you really want to know what is this, keep reading.IntroductionField referenceLines FieldAdditional parametersHow to useAutocomplete Lines FieldAdditional parametersHow to useTinyMCE FieldAdditional parametersHow to useReference FieldAdditional parametersHow to useMultivalued Reference FieldAdditional parametersHow to useCalendar FieldAdditional parametersHow to useLive examplesIntroductionThis is not a form libraryfor Plone, it’s only a set ofZPT macrosthat you can use to
create HTML form in the old way, keeping the Plone layout.
For this reason this product will not handle what to do when you submit the form, it’s only focused onto
rendering some advanced fields.The nice thing is that you can use those macros with the old-way-TTW approach.Field referenceEvery field has some custom options you can/must configure, but some of them are globals:fieldName(mandatory)The name of the field, that is the name you will read from the request when sending the formfieldLabelThe label of the fieldfieldHelpAdditional explanation of the fieldrequiredDisplay the required UI information of the field.Please notethat it’s only a visual effect,
you are in charge of really handle the requirement.cssFieldAdditionalClassesAdditional CSS classes that will be appended to the div containing the whole fieldLines FieldThis field can be used to provide a list of elements (strings) for the submitted form.
Elements are loaded one at time from a text input.The field name will be composed as “fieldName:list”, so you will read a list of element directly from the request.Additional parametersfieldType(default to “text”)The type of the HTML input field used to populate the list. You can change it to
HTML 5 new elements type to use some of the browser native features.patternThe HTML 5 pattern attribute, for field validation. This regex is used to validate the field value before
adding it to the listelementsExistings elements to be used to populate the list. Provide a sequence of dicts with a “title” and “value”
coupleHow to useCall the macro<tal:fielddefine="fieldName string:test_lines_field;
                   fieldLabel string:Testing lines field;
                   fieldHelp string:Write something, then add it;
                   "><metal:field-contentuse-macro="context/@@rt.zptformfield.lines/field"/></tal:field>You need to include a JavaScript in your final HTML.<metal:headfill-slot="javascript_head_slot"><metal:field-contentuse-macro="context/@@rt.zptformfield.lines/javascript_helpers"/></metal:head>Autocomplete Lines FieldThis field can be used to provide a list of elements (strings) for the submitted form.
Elements are selected by an autocomplete feature obtained throughjQueryUI Autocomplete;
in Plone the easyest way to get this is by installingcollective.js.jqueryui.The field name will be composed as “fieldName:list”, so you will read a list of element directly from the request.Additional parameterssource(mandatory)An URL that jQueryUI will call for getting selectable elements. This call must return a valid JSON sequence with
“value” and “label” elements.elementsExistings elements to be used to populate the list. Provide a sequence of dicts with a “title” and “value”
coupleHow to useCall the macro<tal:fielddefine="fieldName string:test_lines_field;
                   source string:${portal_url}/@@rt.zptformfield.test.vocab;
                   fieldLabel string:Testing autocomplete field;
                   fieldHelp string:Write something and test the autocomplete feature;
                   "><metal:field-contentuse-macro="context/@@rt.zptformfield.autocomplete_lines/field"/></tal:field>You need to include a JavaScript in your final HTML.<metal:headfill-slot="javascript_head_slot"><metal:field-contentuse-macro="context/@@rt.zptformfield.autocomplete_lines/javascript_helpers"/></metal:head>TinyMCE FieldThis field render a textarea and trigger the default Plone WYSIWYG editor on the field (using the Products.TinyMCE features,
version 1.3 or better).Additional parametersrowsNumber of rows of the textareacolsNumber of columns of the textareaconfiguration_methodThe view to be called for obtaining TinyMCE configuration. Do not use for loading the default onesconfiguration_jsonDirectly provide the JSON configuration. Do not use to load it from the “configuration_method”valueDefault text in the fieldHow to useCall the macro<tal:fielddefine="fieldName string:test_lines_field;
                   fieldLabel string:Testing TinyMCE field;
                   fieldHelp string:You can use the WYSIWYG editor below;
                   rows python:15;
                   value string:The cat is on the table;
                   "><metal:field-contentuse-macro="context/@@rt.zptformfield.tinymce/field"/></tal:field>Reference FieldThis field render a selection of a site content using the nativearchetypes.referencebrowserwidgetmachinery. The only problem is that the AJAX callmustbe called on a real Archetypes content that
provide a (not multivalued) reference field of a well know name (even if hidden and never used).The submitted data will be the uuid of the selected document.Additional parametersstartup_directoryThe directory where start browsing the site. Default is the current context.context_helperThe context of which call therefbrowserhelperview. Default is the current context.fake_field_name(mandatory)This field name will not be used in the form, but must be an existing Archetypes reference field name
on the context defined by “context_helper”.search_indexThe TextIndex to be used for the overlay search box. Default is Plone default “SearchableText”.How to useCall the macro<tal:fielddefine="fieldName string:test_reference_field;
                   fake_field_name string:foo_field;
                   fieldLabel string:Testing reference browser field;
                   fieldHelp string:Use the Plone reference browser feature.
                   "><metal:field-contentuse-macro="context/@@rt.zptformfield.reference/field"/></tal:field>In the example above we didn’t providecontext_helperparameter so itmustbe called on a Plone content
that behave the “foo_field” singlevalued reference field.You need to include a JavaScript in your final HTML.<metal:headfill-slot="javascript_head_slot"><metal:field-contentuse-macro="context/@@rt.zptformfield.reference/javascript_helpers"/></metal:head>Multivalued Reference FieldThis is the same as the reference field above, but from the overlay displayed you will be able to select multiple
elements.The submitted data will be the a uuid list of selected documents.Additional parametersSee “Reference Field”How to useCall the macro<tal:fielddefine="fieldName string:test_multivalued_reference_field;
                   fake_field_name string:relatedItems;
                   fieldLabel string:Testing multivalued reference browser field;
                   fieldHelp string:Use the Plone reference browser feature.
                   "><metal:field-contentuse-macro="context/@@rt.zptformfield.multivalued_reference/field"/></tal:field>In the example above we didn’t providecontext_helperparameter so itmustbe called on a Plone content
that behave the “relatedItems” multivalued reference field (by default: all content types).You need to include a JavaScript in your final HTML.<metal:headfill-slot="javascript_head_slot"><metal:field-contentuse-macro="context/@@rt.zptformfield.multivalued_reference/javascript_helpers"/></metal:head>Calendar FieldThis field can be used to submit a date (or date-time) using the Plone default calendar.
Date can be filled by using a set of HTML select elements or with a popup calendar widget.This field is based on Plone inner calendar support (JavaScript and ZPT macros) so you can’t use this outside
Plone.Additional parametersvalueThe date to be displayed (aZope DateTimeobject). Default will not show any date.show_hmBoolean value for showing the hours/minutes widget elements. Default will show them.show_ymdBoolean value for showing the day widget elements. Default will show them.starting_yearInteger value for defining the first year to be used in the year combo box.ending_yearInteger value for defining the last year to be used in the year combo box.future_yearsInteger value for defining how many years in the future (from current date) will be shown
in the calendar widget. Will be ignored ifending_yearis provided.minute_stepIf minutes combobox is shown, define the interval between minutes values. Plone default is 5.calendar_langLanguage of the calendar popup UI. For an old and never fixedPlone bugthe default is to
english language and not to the current language.
Change at your own risk. Also:notethat this parameter is for thejavascript_helpersmacros (see example below)How to useCall the macro<tal:fielddefine="fieldName string:test_calendar_field;
                   fieldLabel string:Testing Calendar field;
                   fieldHelp string:The standard Plone calendar;"><metal:field-contentuse-macro="context/@@rt.zptformfield.calendar/field"/></tal:field>You need to include a JavaScript in your final HTML. Anotherwarningabout the usage ofcalendar_langparameter: it’s buggy.<metal:headfill-slot="javascript_head_slot"tal:define="calendar_lang context/@@plone_portal_state/language;"><metal:field-contentuse-macro="context/@@rt.zptformfield.calendar/javascript_helpers"/></metal:head>Finally, the calendar popup needs some CSS styles:<metal:headfill-slot="style_slot"><linkrel="stylesheet"type="text/css"href="jscalendar/calendar-system.css"tal:attributes="href string:$portal_url/jscalendar/calendar-system.css"/></metal:head>Live examplesThis product contains a set of demo views for all fields. You must activate them by including thetests.zcmlfile.[instance]
eggs +=
    ...
    rt.zptformfield

zcml +=
    ...
    rt.zptformfield:tests.zcmlCheckthe codefor an updated list of examples.AuthorsThis product was developed by RedTurtle Technology team.Changelog0.2.1 (2015-09-08)Calendar popup UI language default to english
[keul]Added a way to change calendar language, but added the
proper warning in the documentation
[keul]Added the missing but neededcalendar_formfieldparameter.
Calendar JavaScript was not working.
[keul]0.2.0 (2014-10-09)Added the Calendar field support and example
[keul]0.1.0a1 (2013-12-18)Initial release