Reference the following code snippets that allow a form to function correctly.
Form definition (newsletter.xml):
< ?xmlversion= " 1.0 " ? >
< formxmlns= " http://www.demandware.com/xml/form/2008-04-19 " >
< fieldformid= " email " label= " Email: " type= " string "
mandatory= " true " max-length= " 50 " / >
< /form >
Controller snippet:
varnewsletterForm=server.forms.getForm( ' newsletter ' );
res.render( ' NewsletterTemplate ' ,{newsletterForm:newsletterForm});
Template snippet:
< form action= " ${URLUtils.url( ' Newsletter-Submit ' )} " method= " POST "
< isprint value= " ${EXPRESSION.attributes} " encoding= " off " / > >
< input type= " input " id= " email "
< isprint value= " ${EXPRESSION.email.attributes} " encoding= " off " / > >
< button type= " submit " > Submit < /button >
< /form >
Which code should a developer insert at the EXPRESSION placeholder in the ISML template snippet above to have the form work as expected?
Correct Answer: A
The controller passes the form object tores.render()under the property namenewsletterForm. SFRA merges render data into the response ViewData, and the resulting information is made available to the ISML template throughpdict. Therefore the correct template reference is:
pdict.newsletterForm
The resulting expressions become:
pdict.newsletterForm.attributes
and
pdict.newsletterForm.email.attributes
The form ' sattributesproperty contains generated form-level HTML attributes, while theemailfield exposes its own generated attributes and state.
Option B uses the form-definition name rather than the property name chosen by the controller. Option C omits thepdictaccess expected in the supplied ISML pattern.
Study Guide reference:Application Development - SFRA forms,server.forms.getForm(), ViewData,pdict, form attributes, and controller-to-template data binding.