Zend_Form-StandardElements.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. <sect1 id="zend.form.standardElements">
  2. <title>Elementos Enviados en el Formulario Estandard de Zend Framework</title>
  3. <para>
  4. Zend Framework viene con clases de elementos concretos cubriendo la
  5. mayoría de los elementos de los formularios HTML. La mayoría simplemente
  6. especifica una vista de ayuda para usar cuando se decora el elemento,
  7. pero varios ofrecen funcionalidad adicional. La siguiente es una lista
  8. de todas las clases, así como también una descripción de la
  9. funcionalidad que ofrecen.
  10. </para>
  11. <sect2 id="zend.form.standardElements.button">
  12. <title>Zend_Form_Element_Button</title>
  13. <para>
  14. Usada para crear elementos HTML de tipo button,
  15. <code>Zend_Form_Element_Button</code> extiende <link linkend="zend.form.standardElements.submit">Zend_Form_Element_Submit</link>,
  16. derivandi sy funcionalidad personalizada. It specifies the 'formButton'
  17. view helper for decoration.
  18. </para>
  19. <para>
  20. Like the submit element, it uses the element's label as the element
  21. value for display purposes; in other words, to set the text of the
  22. button, set the value of the element. The label will be translated
  23. if a translation adapter is present.
  24. </para>
  25. <para>
  26. Because the label is used as part of the element, the button element
  27. uses only the <link linkend="zend.form.standardDecorators.viewHelper">ViewHelper</link>
  28. and <link linkend="zend.form.standardDecorators.dtDdWrapper">DtDdWrapper</link>
  29. decorators.
  30. </para>
  31. <para>
  32. Después de llenar o validar un formulario, se puede verificar si el
  33. botón dado fue clickeado usando el método <code>isChecked()</code>.
  34. </para>
  35. </sect2>
  36. <sect2 id="zend.form.standardElements.captcha">
  37. <title>Zend_Form_Element_Captcha</title>
  38. <para>
  39. Los CAPTCHAs son usados para prevenir el envio automático de
  40. formularios por los robots y otros procesos automatizados.
  41. </para>
  42. <para>
  43. The Captcha form element allows you to specify which
  44. <link linkend="zend.captcha.adapters">Zend_Captcha adapter</link> you
  45. wish to utilize as a form captcha. It then sets this adapter as a
  46. validator to the object, and uses a Captcha decorator for rendering
  47. (which proxies to the captcha adapter).
  48. </para>
  49. <para>
  50. Adapters may be any adapters in <code>Zend_Captcha</code>, as well
  51. as any custom adapters you may have defined elsewhere. To allow
  52. this, you may pass an additional plugin loader type key, 'CAPTCHA'
  53. or 'captcha', when specifying a plugin loader prefix path:
  54. </para>
  55. <programlisting role="php"><![CDATA[
  56. $element->addPrefixPath('My_Captcha', 'My/Captcha/', 'captcha');
  57. ]]>
  58. </programlisting>
  59. <para>
  60. Los Captcha entonces pueden ser cargados usando el método
  61. <code>setCaptcha()</code>, el cual puede tomar una instancia
  62. cualquiera de captcha instance, o el nombre corto del adaptador
  63. captcha:
  64. </para>
  65. <programlisting role="php"><![CDATA[
  66. // instancia concreta:
  67. $element->setCaptcha(new Zend_Captcha_Figlet());
  68. // Usando nombre corto:
  69. $element->setCaptcha('Dumb');
  70. ]]>
  71. </programlisting>
  72. <para>
  73. Si desea cargar sus elementos configuración, especifique la clave
  74. 'captcha' con un array conteniendo la clave 'captcha', o
  75. ambas claves 'captcha' y 'captchaOptions':
  76. </para>
  77. <programlisting role="php"><![CDATA[
  78. // Usindo la clave captcha simple:
  79. $element = new Zend_Form_Element_Captcha('foo', array(
  80. 'label' => "Please verify you're a human",
  81. 'captcha' => array(
  82. 'captcha' => 'Figlet',
  83. 'wordLen' => 6,
  84. 'timeout' => 300,
  85. ),
  86. ));
  87. // Usindo captcha y captchaOptions:
  88. $element = new Zend_Form_Element_Captcha('foo', array(
  89. 'label' => "Please verify you're a human"
  90. 'captcha' => 'Figlet',
  91. 'captchaOptions' => array(
  92. 'captcha' => 'Figlet',
  93. 'wordLen' => 6,
  94. 'timeout' => 300,
  95. ),
  96. ));
  97. ]]>
  98. </programlisting>
  99. <para>
  100. El decorador usado es determinado consultando el adaptador captcha.
  101. Por defecto, es usado el
  102. <link linkend="zend.form.standardDecorators.captcha">Captcha
  103. decorator</link>, pero un adaptadpr puede especificar uno
  104. diferente vía su método<code>getDecorator()</code>.
  105. </para>
  106. <para>
  107. Como ha notado, el adaptador captcha actúa él mismo como un validador
  108. para el elemento. Adicionalmente, el validador NotEmpty validator
  109. no es usado y el elemento es marcado como requerido. Enla mayoría de
  110. los casos, usted no necesitará hacer nada más para tener un captcha
  111. presente en su formulario.
  112. </para>
  113. </sect2>
  114. <sect2 id="zend.form.standardElements.checkbox">
  115. <title>Zend_Form_Element_Checkbox</title>
  116. <para>
  117. Las casillas de verigicación (checkboxes) HTML le permiten devolver
  118. un valor específico, pero básicamente operata como los booleanos:
  119. cuando está marcada, el valor es enviado; cuando no está marcada, no se envía nada. Internamente, Zend_Form_Element_Checkbox forza este
  120. estado.
  121. </para>
  122. <para>
  123. Por defecto, si la casilla (checkbox) está marcada su valor es '1',
  124. y si no está marcada su valor es '0'.
  125. You can specify the values to use using the
  126. <code>setCheckedValue()</code> and <code>setUncheckedValue()</code>
  127. accessors, respectively. Internally, any time you set the value, if
  128. the provided value matches the checked value, then it is set, but
  129. any other value causes the unchecked value to be set.
  130. </para>
  131. <para>
  132. Additionally, setting the value sets the <code>checked</code>
  133. property of the checkbox. You can query this using
  134. <code>isChecked()</code> or simply accessing the property. Using the
  135. <code>setChecked($flag)</code> method will both set the state of the
  136. flag as well as set the appropriate checked or unchecked value in the
  137. element. Please use this method when setting the checked state of a
  138. checkbox element to ensure the value is set properly.
  139. </para>
  140. <para>
  141. <code>Zend_Form_Element_Checkbox</code> uses the 'formCheckbox' view
  142. helper. The checked value is always used to populate it.
  143. </para>
  144. </sect2>
  145. <sect2 id="zend.form.standardElements.file">
  146. <title>Zend_Form_Element_File</title>
  147. <para>
  148. The File form element provides a mechanism for supplying file upload
  149. fields to your form. It utilizes <link linkend="zend.file.transfer.introduction">Zend_File_Transfer</link>
  150. internally to provide this functionality, and the
  151. <code>FormFile</code> view helper as also the <code>File</code>
  152. decorator to display the form element.
  153. </para>
  154. <para>
  155. By default, it uses the <code>Http</code> transfer adapter, which
  156. introspects the <code>$_FILES</code> array and allows you to attach
  157. validators and filters. Validators and filters attached to the form
  158. element will be attached to the transfer adapter.
  159. </para>
  160. <example id="zend.form.standardElements.file.usage">
  161. <title>File form element usage</title>
  162. <para>
  163. The above explanation of using the File form element may seem
  164. arcane, but actual usage is relatively trivial:
  165. </para>
  166. <programlisting role="php"><![CDATA[
  167. $element = new Zend_Form_Element_File('foo');
  168. $element->setLabel('Upload an image:')
  169. ->setDestination('/var/www/upload');
  170. // ensure only 1 file
  171. $element->addValidator('Count', false, 1);
  172. // limit to 100K
  173. $element->addValidator('Size', false, 102400);
  174. // only JPEG, PNG, and GIFs
  175. $element->addValidator('Extension', false, 'jpg,png,gif');
  176. $form->addElement($element, 'foo');
  177. ]]>
  178. </programlisting>
  179. <para>
  180. También debe asegurarse de que se ha provisto un tipo de
  181. codificación corecto al formulario; se debe utilizar
  182. 'multipart/form-data'. Se puede hacer esto estableciendo el
  183. atributo 'enctype' en el formulario:
  184. </para>
  185. <programlisting role="php"><![CDATA[
  186. $form->setAttrib('enctype', 'multipart/form-data');
  187. ]]>
  188. </programlisting>
  189. <para>
  190. Cuando el atributo ha sido validado exitosamente, usted debe
  191. recibir el archivo para alamacenarlo en el destino final
  192. usando receive(). Adicionalmente puede determinar la
  193. ubicación final usando getFileName():
  194. </para>
  195. <programlisting role="php"><![CDATA[
  196. if (!$form->isValid) {
  197. print "Ohoh... validation error";
  198. }
  199. if (!$form->foo->receive()) {
  200. print "Error receiving the file";
  201. }
  202. $location = $form->foo->getFileName();
  203. ]]>
  204. </programlisting>
  205. </example>
  206. <note>
  207. <title>Ubicaciones Predeterminadas para la Carga de Archivos</title>
  208. <para>
  209. Por defecto, los archivos son cargados al directorio temp del
  210. sistema.
  211. </para>
  212. </note>
  213. <note>
  214. <title>Valores de archivo</title>
  215. <para>
  216. Dentro de HTTP un elemento file no tiene valor. Por tanto y a
  217. causa de razones de seguridad usted solo obtendrá el nombre del
  218. archivo cargado llamando a getValue() y no el destino completo.
  219. si usted necesita la información completa llame getFileName() y
  220. le retormará el destino y nombre de archivo completo.
  221. </para>
  222. </note>
  223. <para>
  224. <code>Zend_Form_Element_File</code> soporta también archivos
  225. múltiples. Para llamar el método <code>setMultiFile($count)</code>
  226. usted puede establecer la cantidad de elementos file que usted desea
  227. crear. Esto le previene de establecer la misma configuración varias
  228. veces.
  229. </para>
  230. <example id="zend.form.standardElements.file.multiusage">
  231. <title>Configuración de múltiples archivos</title>
  232. <para>
  233. Crear un elemento multi archivo es lo mismo que querer configurar
  234. un elemento único. Sólo tiene que llamar a
  235. <code>setMultiFile()</code> adicionalmente después de la creación:
  236. </para>
  237. <programlisting role="php"><![CDATA[
  238. $element = new Zend_Form_Element_File('foo');
  239. $element->setLabel('Upload an image:')
  240. ->setDestination('/var/www/upload');
  241. // asegura mínimo 1, maximo 3 archivos
  242. $element->addValidator('Count', false, array('min' => 1, 'max' => 3));
  243. // limita a 100K
  244. $element->addValidator('Size', false, 102400);
  245. // solo JPEG, PNG, y GIFs
  246. $element->addValidator('Extension', false, 'jpg,png,gif');
  247. // define 3 elementos file idénticos
  248. $element->setMultiFile(3);
  249. $form->addElement($element, 'foo');
  250. ]]>
  251. </programlisting>
  252. <para>
  253. En su vista usted ahora obtendrá 3 elementos para carga de
  254. archivos idénticos los cuales comparten la misma configuración.
  255. para obtener el conjunto de el número de archivos múltiples
  256. simplemente llame <code>getMultiFile()</code>.
  257. </para>
  258. </example>
  259. <note>
  260. <title>Elementos File en Subformularioss</title>
  261. <para>
  262. Cuando usted use elementos file in subformularios debería
  263. establecer nombres únicos.
  264. Así, cuando usted nombre su elemento file en el subformulario1,
  265. debe darle un nombre diferente el el subformulario2.
  266. </para>
  267. <para>
  268. Tan pronto como haya dos elementos file nombrados de forma
  269. idéntica, el segundo elemento no se mostrará o enviará.
  270. </para>
  271. </note>
  272. <para>
  273. Para limitar el tamaño del archivo, el cual es cargado por el
  274. cliente, debe establecer el tamaño máximo de archivo que el
  275. formulario acepta . Esto limitará eñ tamaño del archivo en el lado
  276. del cliente configurando la opción <code>MAX_FILE_SIZE</code>
  277. en el formulario. Tan pronto como establesca este valor usando
  278. el método <code>setMaxFileSize($size)</code>, estó será generado
  279. con el elemento file.
  280. </para>
  281. <programlisting role="php"><![CDATA[
  282. $element = new Zend_Form_Element_File('foo');
  283. $element->setLabel('Upload an image:')
  284. ->setDestination('/var/www/upload')
  285. ->addValidator('Size', false, 102400) // límite en 100K
  286. ->setMaxFileSize(102400); // limita el tamaño del archivo en el lado del cliente
  287. $form->addElement($element, 'foo');
  288. ]]>
  289. </programlisting>
  290. <note>
  291. <title>MaxFileSize con elementos file múltiples</title>
  292. <para>
  293. Cuando usted usa elementos file múltiples en los formularios tiene
  294. que establecer el <code>MAX_FILE_SIZE</code> una sola vez.
  295. Establecerlo otra vez sobreescribirá el valor previamente
  296. establecido.
  297. </para>
  298. <para>
  299. Note, que usted puede establecer <code>MAX_FILE_SIZE</code>
  300. una sola ves, incluso si usas múltiples formularios.
  301. </para>
  302. </note>
  303. </sect2>
  304. <sect2 id="zend.form.standardElements.hidden">
  305. <title>Zend_Form_Element_Hidden</title>
  306. <para>
  307. Los elementos Hidden simplemente injectan datos que deben ser
  308. enviados, pero que el usuario no debe manipular.
  309. <code>Zend_Form_Element_Hidden</code> logra esto através del uso de
  310. el helper de vista 'formHidden'.
  311. </para>
  312. </sect2>
  313. <sect2 id="zend.form.standardElements.hash">
  314. <title>Zend_Form_Element_Hash</title>
  315. <para>
  316. Este elemento provee protección de ataques desde CSRF sobre
  317. formularios, asegurando que el dato es enviado por la sesión del
  318. usuario que generó el formulario y no por un script pillero.
  319. La protección se logra mediante la adición de un elemento hash a
  320. un formulario y verificandolo cuando el formulario es enviado.
  321. </para>
  322. <para>
  323. El nombre del elemnto hash debe ser único. Se recomienda usar la
  324. opción <literal>salt</literal> para el elemento, dos hashes con
  325. el mismo nombre y diferentes salts no chocan:
  326. </para>
  327. <programlisting role="php"><![CDATA[
  328. $form->addElement('hash', 'no_csrf_foo', array('salt' => 'unique'));
  329. ]]>
  330. </programlisting>
  331. <para>
  332. Puede establecer el salt más tarde usando el método
  333. <code>setSalt($salt)</code>.
  334. </para>
  335. <para>
  336. Internamente, el elemento alamacena un identificador único usando
  337. <code>Zend_Session_Namespace</code>, y lo comprueba en el momento
  338. que se envía (comprueba que el TTL has no espiró). El validador
  339. 'Identical' entonces es usado para asegurarse que el hash enviado
  340. marcha con el hash alamacenado.
  341. </para>
  342. <para>
  343. El helper de vista 'formHidden' es usado par generar el elemento
  344. en el formulario.
  345. form.
  346. </para>
  347. </sect2>
  348. <sect2 id="zend.form.standardElements.Image">
  349. <title>Zend_Form_Element_Image</title>
  350. <para>
  351. Las imáagenes pueden ser usadas como elmentos de formulario, y le
  352. permite especificar elementos gráficos como botones de formulario.
  353. </para>
  354. <para>
  355. Los elementos Image necesitan una imagen fuente.
  356. <code>Zend_Form_Element_Image</code> le permite especificar esto
  357. usando el método de acceso <code>setImage()</code>
  358. (o clave de configuración 'image'). Opcionalmente, también puede
  359. especificar un valor para utilizar al momento de enviar la imagen
  360. utilizando el método de acceso <code>setImageValue()</code>
  361. (o clave de configuración 'imageValue'). Cuando el valor establecido
  362. para el elemento son similares al <code>imageValue</code>, entonces
  363. el método de acceso <code>isChecked()</code> devolverá true.
  364. </para>
  365. <para>
  366. El elemento Image usa el
  367. <link linkend="zend.form.standardDecorators.image">Decorador de
  368. Imagen </link> para generar (así como el estandard Errors,
  369. HtmlTag, y decorador Label). Opcionalmente, puede especificar una
  370. etiqueta para el decorador <code>Image</code> que luego
  371. envuelva al elemento imagen.
  372. </para>
  373. </sect2>
  374. <sect2 id="zend.form.standardElements.multiCheckbox">
  375. <title>Zend_Form_Element_MultiCheckbox</title>
  376. <para>
  377. A menudo tiene un conjunto de checkboxes, y desea agrupar los
  378. resultados. Esto es como un
  379. <link linkend="zend.form.standardElements.multiselect">Multiselect</link>,
  380. pero en lugar de estar en una lista desplegable, necesita mostrarlos en pares checkbox/value (casilla de verificación/valor).
  381. </para>
  382. <para>
  383. <code>Zend_Form_Element_MultiCheckbox</code> hace esto sencillo. Like
  384. all other elements extending the base Multi element, you can specify
  385. a list of options, and easily validate against that same list. The
  386. 'formMultiCheckbox' view helper ensures that these are returned as
  387. an array in the form submission.
  388. </para>
  389. <para>
  390. By default, this element registers an <code>InArray</code> validator
  391. which validates against the array keys of registered options. You
  392. can disable this behavior by either calling
  393. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  394. false value to the <code>registerInArrayValidator</code>
  395. configuration key.
  396. </para>
  397. <para>
  398. You may manipulate the various checkbox options using the following
  399. methods:
  400. </para>
  401. <itemizedlist>
  402. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  403. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  404. <listitem><para><code>setMultiOptions(array $options)</code>
  405. (overwrites existing options)</para></listitem>
  406. <listitem><para>getMultiOption($option)</para></listitem>
  407. <listitem><para>getMultiOptions()</para></listitem>
  408. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  409. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  410. </itemizedlist>
  411. <para>
  412. To mark checked items, you need to pass an array of values to
  413. <code>setValue()</code>. The following will check the values "bar"
  414. and "bat":
  415. </para>
  416. <programlisting role="php"><![CDATA[
  417. $element = new Zend_Form_Element_MultiCheckbox('foo', array(
  418. 'multiOptions' => array(
  419. 'foo' => 'Foo Option',
  420. 'bar' => 'Bar Option',
  421. 'baz' => 'Baz Option',
  422. 'bat' => 'Bat Option',
  423. );
  424. ));
  425. $element->setValue(array('bar', 'bat'));
  426. ]]>
  427. </programlisting>
  428. <para>
  429. Note that even when setting a single value, you must pass an array.
  430. </para>
  431. </sect2>
  432. <sect2 id="zend.form.standardElements.multiselect">
  433. <title>Zend_Form_Element_Multiselect</title>
  434. <para>
  435. XHTML <code>select</code> elements allow a 'multiple' attribute,
  436. indicating multiple options may be selected for submission, instead
  437. of the usual one. <code>Zend_Form_Element_Multiselect</code> extends
  438. <link linkend="zend.form.standardElements.select">Zend_Form_Element_Select</link>,
  439. and sets the <code>multiple</code> attribute to 'multiple'. Like
  440. other classes that inherit from the base
  441. <code>Zend_Form_Element_Multi</code> class, you can manipulate the
  442. options for the select using:
  443. </para>
  444. <itemizedlist>
  445. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  446. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  447. <listitem><para><code>setMultiOptions(array $options)</code>
  448. (overwrites existing options)</para></listitem>
  449. <listitem><para>getMultiOption($option)</para></listitem>
  450. <listitem><para>getMultiOptions()</para></listitem>
  451. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  452. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  453. </itemizedlist>
  454. <para>
  455. If a translation adapter is registered with the form and/or element,
  456. option values will be translated for display purposes.
  457. </para>
  458. <para>
  459. By default, this element registers an <code>InArray</code> validator
  460. which validates against the array keys of registered options. You
  461. can disable this behavior by either calling
  462. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  463. false value to the <code>registerInArrayValidator</code>
  464. configuration key.
  465. </para>
  466. </sect2>
  467. <sect2 id="zend.form.standardElements.password">
  468. <title>Zend_Form_Element_Password</title>
  469. <para>
  470. Password elements are basically normal text elements -- except that
  471. you typically do not want the submitted password displayed in error
  472. messages or the element itself when the form is re-displayed.
  473. </para>
  474. <para>
  475. <code>Zend_Form_Element_Password</code> achieves this by calling
  476. <code>setObscureValue(true)</code> on each validator (ensuring that
  477. the password is obscured in validation error messages), and using
  478. the 'formPassword' view helper (which does not display the value
  479. passed to it).
  480. </para>
  481. </sect2>
  482. <sect2 id="zend.form.standardElements.radio">
  483. <title>Zend_Form_Element_Radio</title>
  484. <para>
  485. Radio elements allow you to specify several options, of which you
  486. need a single value returned. <code>Zend_Form_Element_Radio</code>
  487. extends the base <code>Zend_Form_Element_Multi</code> class,
  488. allowing you to specify a number of options, and then uses the
  489. <code>formRadio</code> view helper to display these.
  490. </para>
  491. <para>
  492. By default, this element registers an <code>InArray</code> validator
  493. which validates against the array keys of registered options. You
  494. can disable this behavior by either calling
  495. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  496. false value to the <code>registerInArrayValidator</code>
  497. configuration key.
  498. </para>
  499. <para>
  500. Like all elements extending the Multi element base class, the
  501. following methods may be used to manipulate the radio options
  502. displayed:
  503. </para>
  504. <itemizedlist>
  505. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  506. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  507. <listitem><para><code>setMultiOptions(array $options)</code>
  508. (overwrites existing options)</para></listitem>
  509. <listitem><para>getMultiOption($option)</para></listitem>
  510. <listitem><para>getMultiOptions()</para></listitem>
  511. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  512. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  513. </itemizedlist>
  514. </sect2>
  515. <sect2 id="zend.form.standardElements.reset">
  516. <title>Zend_Form_Element_Reset</title>
  517. <para>
  518. Reset buttons are typically used to clear a form, and are not part
  519. of submitted data. However, as they serve a purpose in the display,
  520. they are included in the standard elements.
  521. </para>
  522. <para>
  523. <code>Zend_Form_Element_Reset</code> extends <link linkend="zend.form.standardElements.submit">Zend_Form_Element_Submit</link>.
  524. As such, the label is used for the button display, and will be
  525. translated if a translation adapter is present. It utilizes only the
  526. 'ViewHelper' and 'DtDdWrapper' decorators, as there should never be
  527. error messages for such elements, nor will a label be necessary.
  528. </para>
  529. </sect2>
  530. <sect2 id="zend.form.standardElements.select">
  531. <title>Zend_Form_Element_Select</title>
  532. <para>
  533. Select boxes are a common way of limiting to specific choices for a
  534. given form datum. <code>Zend_Form_Element_Select</code> allows you
  535. to generate these quickly and easily.
  536. </para>
  537. <para>
  538. By default, this element registers an <code>InArray</code> validator
  539. which validates against the array keys of registered options. You
  540. can disable this behavior by either calling
  541. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  542. false value to the <code>registerInArrayValidator</code>
  543. configuration key.
  544. </para>
  545. <para>
  546. As it extends the base Multi element, the following methods may be
  547. used to manipulate the select options:
  548. </para>
  549. <itemizedlist>
  550. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  551. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  552. <listitem><para><code>setMultiOptions(array $options)</code>
  553. (overwrites existing options)</para></listitem>
  554. <listitem><para>getMultiOption($option)</para></listitem>
  555. <listitem><para>getMultiOptions()</para></listitem>
  556. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  557. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  558. </itemizedlist>
  559. <para>
  560. <code>Zend_Form_Element_Select</code> uses the 'formSelect' view
  561. helper for decoration.
  562. </para>
  563. </sect2>
  564. <sect2 id="zend.form.standardElements.submit">
  565. <title>Zend_Form_Element_Submit</title>
  566. <para>
  567. Submit buttons are used to submit a form. You may use multiple
  568. submit buttons; you can use the button used to submit the form to
  569. decide what action to take with the data submitted.
  570. <code>Zend_Form_Element_Submit</code> makes this decisioning easy,
  571. by adding a <code>isChecked()</code> method; as only one button
  572. element will be submitted by the form, after populating or
  573. validating the form, you can call this method on each submit button
  574. to determine which one was used.
  575. </para>
  576. <para>
  577. <code>Zend_Form_Element_Submit</code> uses the label as the "value"
  578. of the submit button, translating it if a translation adapter is
  579. present. <code>isChecked()</code> checks the submitted value against
  580. the label in order to determine if the button was used.
  581. </para>
  582. <para>
  583. The <link linkend="zend.form.standardDecorators.viewHelper">ViewHelper</link>
  584. and <link linkend="zend.form.standardDecorators.dtDdWrapper">DtDdWrapper</link>
  585. decorators to render the element. No label decorator is used, as the
  586. button label is used when rendering the element; also, typically,
  587. you will not associate errors with a submit element.
  588. </para>
  589. </sect2>
  590. <sect2 id="zend.form.standardElements.text">
  591. <title>Zend_Form_Element_Text</title>
  592. <para>
  593. By far the most prevalent type of form element is the text element,
  594. allowing for limited text entry; it's an ideal element for most data
  595. entry. <code>Zend_Form_Element_Text</code> simply uses the
  596. 'formText' view helper to display the element.
  597. </para>
  598. </sect2>
  599. <sect2 id="zend.form.standardElements.textarea">
  600. <title>Zend_Form_Element_Textarea</title>
  601. <para>
  602. Textareas are used when large quantities of text are expected, and
  603. place no limits on the amount of text submitted (other than maximum
  604. size limits as dictated by your server or PHP).
  605. <code>Zend_Form_Element_Textarea</code> uses the 'textArea' view
  606. helper to display such elements, placing the value as the content of
  607. the element.
  608. </para>
  609. </sect2>
  610. </sect1>
  611. <!--
  612. vim:se ts=4 sw=4 tw=80 et:
  613. -->