Adding attributes to cq5 form using FormsHelper - aem

I'm trying to add an attribute to the form tag of a cq5 form. I noticed that the output is generated using
FormsHelper.startForm(slingRequest, new JspSlingHttpServletResponseWrapper(pageContext));
I was curious how I can either:
alter the request so that the formHelper prints the form w/ the attributes I need
Hook into the actual print out to include the attributes I need.
Any help or direction would be good.
note:
I've already checkout out the javadoc for formshelper, done some searching via goolgle, and dev.day.com including the dev.day.com doc on developing forms.
thank you

API doesn't allow you to add any attributes to this tag. You can only specify desired CSS classes adding css property to the form component. Of course, you can also create component sling filter and response wrapper to rewrite created form, but it seems to be an overkill. I think better solution is using JS to add attributes client-side.

Related

Prefilled notes of Class attributes in Enterprise architect

is there a way to have prefilled attributes notes in enterprise architect?
It should be something like this scenario:
1) I create new attribute
2) Enterprise architect prefill note of attribute with predefined text
Something like template for attributes.
Thank you for any advice
I know this won't help directly this question.
Anyways you can achieve it through an external addin.
All you need to do is handle the EA_OnPreNewAttribute and EA_OnPostNewAttribute broadcast events .
This isn't quite what you're after but it is possible to create an Attribute stereotype in a Profile and add to this a Tag with an initial value set to what ever you want. When you create an attribute with this stereotype, this means your predefined text would appear in a tag-value for the attribute rather than the note. Not ideal, but might work for you.
You could also have a go at writing some JavaScript to do this as well (under Scripting in EA). You'd have to use the JS to navigate the repository structure, find the attributes in question, and update their note. I don't believe you can attach a script to a UI event, so I think you'd be stuck running this post-hoc rather than having the note auto-populate on attribute creation.

How to check when a form was rendered in Laravel

Upon a form a submission, I wish to determine the time that a Laravel form (built using the Laravel Collective HTML package) was rendered to the user.
I need to check this date upon submission for a variety of reasons.
I have a large existing project and am considering the best way to get this date. I was reading the CSRF middleware (since this token is already included in all forms) to see if it can be extracted from that, perhaps in another middleware adding something like form_generated_date to the request.
It looks like a bit of a stretch, if possible at all. So now I am looking at adding a custom field to every form.
I would like this to be included in all forms, just as the Form::open() method will add the CSRF token. I found information on adding my own macros, but not about extending this method.
Does anyone know if it's possible to get the date from a CSRF token? Or how (or where the documentation is) to extend the Form::open() method.
The Form::open() method looks to be in the FormBuilder.php file (https://github.com/LaravelCollective/html/blob/2f6dc39ab3655724a615fe8a652d8b7f04fc9ac6/src/FormBuilder.php).
This file can be found in /vendor/laravelcollective/html/src/FormBuilder.php
You should be able to add a new hidden form field to the open method, bearing in mind that this will be overwritten in any updates. Not really recommended, but will achieve what you are looking for.

Is there / What is a suggested way to create autocompleted form fields in ZF2?

Does the ZF2 Form (zendframework/zend-form) provide a mechanism to create text fields with autocompleted value list? Or is it just done by using the common Zend\Form\Element\Text, a Controller, that provides the data, and some JavaScript (not by ZF generated, but implemented in any proper way)?
You can use jQuery Autocomplete field with Any Framework or CMS, You can grab it here. https://jqueryui.com/autocomplete/
Its quite simple and easy to use.
You can fill source array on document.ready() or on field.change() or on field.keypress() events as per your requirements using Ajax.
Or you can read similar Resolved issue here
JQuery UI Autocomplete with Zend Framework
Zend Form doesn't have such mechanism, so proper way is use AJAX request with JSON response. See Rob Allen's tutorial for this:
Returning JSON from a ZF2 controller action

How to extract labels from Symfony forms I18n Extract Task

I am quite aware that the extract task accepts application as a parameter, and thus one can't expect it too look into the forms folder.
However, I referred the link (below) and tried a couple of ways:
1. defining my proxy __() method
2. including the I18n helper in App Configuration
However, both aren't working.
Can anyone tell me how to extract these from the form classes?
Thanks
http://groups.google.com/group/symfony-devs/browse_thread/thread/1d034f5f7367fe0c
You need to use the i18n helper and add the translated strings manually to your XML/XLIFF files. The translations themselves work, it's just the i18n:extract task that doesn't look inside form classes so it has to be done manually. I hope they add this feature in Symfony 2.0.
See the first few paragraphs here: http://www.symfony-project.org/forms/1_4/en/08-Internationalisation-and-Localisation
There's a way to extract it altough it's not recommended by the developers:
In lib/i18n/extract/sfI18nApplicationExtract.class.php add:
$this->extractFromPhpFiles(sfConfig::get('sf_lib_dir').'/form');
to function extract()
In your form class's configure method add:
sfLoader::loadHelpers('I18N');
This way you can use the __() function in your form class.
I'm currently testing it. Will share my findings.

Changing output of Forms with Struts+Freemarker

I'm working on a Website with Struts2 and Freemarker.
Whenever I add form tags such as:
<#s.form action="foo">
<#s.combobox (...)/>
It generates a bunch of html/css/javascript that I don't need.
Is there any way I can specify that no extra elements should be generated or do I really need to go into Freemarker.jar and edit the templates to my liking?
Have you read about "themes" in struts2 tags ?
http://struts.apache.org/2.x/docs/why-do-the-form-tags-put-table-tags-around-controls.html
http://struts.apache.org/2.x/docs/themes-and-templates.html