Skip to content
Tim Curzon edited this page Feb 28, 2022 · 3 revisions

Form Tales

The Form tales are mainly used within the ZTal form macros to support rendering Zend_Form objects. However, they are available if you wish to replace some or all of the form macros with your own template code.

All the form tales are used in the form Ztal\Tales\Form. followed by the name of the tale - see the examples for more info.


getAttrib

Fetch a named attribute from the supplied Zend_Form_Element

<input tal:attributes="maxlength Ztal\Tales\Form.getAttrib:element,attribute" />

getElement

Fetch a named element from the supplied Zend_Form

<tal:block tal:define="element Ztal\Tales\Form.getElement:element,name" />

getErrors

Fetch the errors for a named element from the supplied Zend_Form

<tal:block tal:define="element Ztal\Tales\Form.getErrors:form,elementName" />

inputType

Determine the input field type for a Zend_Form_Element

<input tal:attributes="type Ztal\Tales\Form.inputType:element" />

isDisplayGroup

Determine whether the current element is actually a display group

<fieldset tal:condition="Ztal\Tales\Form.isDisplayGroup:element"></fieldset>

isFormElement

Determine whether the current element is a standard element such as input or select.

<input tal:condition="Ztal\Tales\Form.isFormElement:element" />

isHiddenElement

Determine whether the current element is a hidden element.

<input tal:condition="Ztal\Tales\Form.isHiddenElement:element" />

isButton

Determine whether the current element is a button element.

<button tal:condition="Ztal\Tales\Form.isButton:element" />

isImageCaptcha

Determine whether the current element is an image captcha

<span tal:condition="Ztal\Tales\Form.isImageCaptcha:element" />

isCaptcha

Determine whether the current element is an non-image captcha

<span tal:condition="Ztal\Tales\Form.isCaptcha:element" />

isChecked

Determine whether the current option in a multiCheckbox should be checked.

<tal:block tal:define="checked Ztal\Tales\Form.isChecked:element,currentOption" />

isDisabled

Determine whether the current element is disabled.

<tal:block tal:attributes="disabled Ztal\Tales\Form.isDisabled:element" />

isInput

Determine whether the current element is an input element.

<input tal:condition="Ztal\Tales\Form.isInput:element" />

isMultiCheckbox

Determine whether the current element is a multiCheckbox element.

<input tal:condition="Ztal\Tales\Form.isMultiCheckbox:element" />

isRadio

Determine whether the current element is a radio element.

<input tal:condition="Ztal\Tales\Form.isRadio:element" />

isCheckbox

Determine whether the current element is a checkbox element.

<input tal:condition="Ztal\Tales\Form.isCheckbox:element" />

isSelect

Determine whether the current element is a select element.

<input tal:condition="Ztal\Tales\Form.isSelect:element" />

isMultiSelect

Determine whether the current element is a multiSelect element.

<input tal:condition="Ztal\Tales\Form.isMultiSelect:element" />

isTextarea

Determine whether the current element is a textarea element.

<textarea tal:condition="Ztal\Tales\Form.isTextarea:element" />

showLabelBefore

Determine whether to show the label before the element.

<label tal:condition="Ztal\Tales\Form.showLabelBefore:element" />

showLabelAfter

Determine whether to show the label after the element.

<label tal:condition="Ztal\Tales\Form.showLabelAfter:element" />

getSlotContent

Fetch content for a possible slot of the supplied name (that does not need to exist)

<tal:block tal:define="slotContent Ztal\Tales\Form.getSlotContent:slotName" />