Zend_Form-StandardElements.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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 pulsado 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 adaptador 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
  109. no es usado y el elemento es marcado como requerido. En la 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 verificación (checkboxes) HTML le permiten devolver
  118. un valor específico, pero básicamente funcionan 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 fuerza 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 almacenarlo 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 a getFileName() y
  220. le devolverá 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 del número de archivos múltiples
  256. simplemente llame a <code>getMultiFile()</code>.
  257. </para>
  258. </example>
  259. <note>
  260. <title>Elementos File en Subformularioss</title>
  261. <para>
  262. Cuando usted use elementos file en subformularios debería
  263. establecer nombres únicos.
  264. Así, cuando usted nombre su elemento file en el subformulario1,
  265. debe darle un nombre diferente en 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á el 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 establezca este valor usando
  278. el método <code>setMaxFileSize($size)</code>, 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 vez, incluso si usa 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 inyectan datos que deben ser
  308. enviados, pero que el usuario no debe manipular.
  309. <code>Zend_Form_Element_Hidden</code> logra esto a través del uso del helper de vista 'formHidden'.
  310. </para>
  311. </sect2>
  312. <sect2 id="zend.form.standardElements.hash">
  313. <title>Zend_Form_Element_Hash</title>
  314. <para>
  315. Este elemento provee protección de ataques desde CSRF sobre
  316. formularios, asegurando que el dato es enviado por la sesión del
  317. usuario que generó el formulario y no por un script malicioso.
  318. La protección se logra mediante la adición de un elemento hash a
  319. un formulario y verificandolo cuando el formulario es enviado.
  320. </para>
  321. <para>
  322. El nombre del elemento hash debe ser único. Se recomienda usar la
  323. opción <literal>salt</literal> para el elemento, dos hashes con
  324. el mismo nombre y diferentes salts no chocan:
  325. </para>
  326. <programlisting role="php"><![CDATA[
  327. $form->addElement('hash', 'no_csrf_foo', array('salt' => 'unique'));
  328. ]]>
  329. </programlisting>
  330. <para>
  331. Puede establecer el salt más tarde usando el método
  332. <code>setSalt($salt)</code>.
  333. </para>
  334. <para>
  335. Internamente, el elemento almacena un identificador único usando
  336. <code>Zend_Session_Namespace</code>, y lo comprueba en el momento
  337. que se envía (comprueba que el TTL no ha espirado). El validador
  338. 'Identical' entonces es usado para asegurarse que el hash enviado
  339. marcha con el hash alamacenado.
  340. </para>
  341. <para>
  342. El helper de vista 'formHidden' es usado para generar el elemento
  343. en el formulario.
  344. </para>
  345. </sect2>
  346. <sect2 id="zend.form.standardElements.Image">
  347. <title>Zend_Form_Element_Image</title>
  348. <para>
  349. Las imágenes pueden ser usadas como elementos de formulario, y le
  350. permiten especificar elementos gráficos como botones de formulario.
  351. </para>
  352. <para>
  353. Los elementos Image necesitan una imagen fuente.
  354. <code>Zend_Form_Element_Image</code> le permite especificar esto
  355. usando el método de acceso <code>setImage()</code>
  356. (o clave de configuración 'image'). Opcionalmente, también puede
  357. especificar un valor para utilizar al momento de enviar la imagen
  358. utilizando el método de acceso <code>setImageValue()</code>
  359. (o clave de configuración 'imageValue'). Cuando el valor establecido
  360. para el elemento sea igual a <code>imageValue</code>, entonces
  361. el método de acceso <code>isChecked()</code> devolverá true.
  362. </para>
  363. <para>
  364. Los elementos Image usan el
  365. <link linkend="zend.form.standardDecorators.image">Decorador de
  366. Imagen </link> para generar (así como el estandard Errors,
  367. HtmlTag, y decorador Label). Opcionalmente, puede especificar una
  368. etiqueta para el decorador <code>Image</code> que luego
  369. envuelva al elemento imagen.
  370. </para>
  371. </sect2>
  372. <sect2 id="zend.form.standardElements.multiCheckbox">
  373. <title>Zend_Form_Element_MultiCheckbox</title>
  374. <para>
  375. En ocasiones, se tiene un conjunto de checkboxes, y se desea agrupar los
  376. resultados. Esto es como un
  377. <link linkend="zend.form.standardElements.multiselect">Multiselect</link>,
  378. pero en lugar de estar en una lista desplegable, necesita mostrarlos en pares checkbox/value (casilla de verificación/valor).
  379. </para>
  380. <para>
  381. <code>Zend_Form_Element_MultiCheckbox</code> hace esto sencillo. Like
  382. all other elements extending the base Multi element, you can specify
  383. a list of options, and easily validate against that same list. The
  384. 'formMultiCheckbox' view helper ensures that these are returned as
  385. an array in the form submission.
  386. </para>
  387. <para>
  388. By default, this element registers an <code>InArray</code> validator
  389. which validates against the array keys of registered options. You
  390. can disable this behavior by either calling
  391. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  392. false value to the <code>registerInArrayValidator</code>
  393. configuration key.
  394. </para>
  395. <para>
  396. You may manipulate the various checkbox options using the following
  397. methods:
  398. </para>
  399. <itemizedlist>
  400. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  401. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  402. <listitem><para><code>setMultiOptions(array $options)</code>
  403. (overwrites existing options)</para></listitem>
  404. <listitem><para>getMultiOption($option)</para></listitem>
  405. <listitem><para>getMultiOptions()</para></listitem>
  406. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  407. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  408. </itemizedlist>
  409. <para>
  410. To mark checked items, you need to pass an array of values to
  411. <code>setValue()</code>. The following will check the values "bar"
  412. and "bat":
  413. </para>
  414. <programlisting role="php"><![CDATA[
  415. $element = new Zend_Form_Element_MultiCheckbox('foo', array(
  416. 'multiOptions' => array(
  417. 'foo' => 'Foo Option',
  418. 'bar' => 'Bar Option',
  419. 'baz' => 'Baz Option',
  420. 'bat' => 'Bat Option',
  421. );
  422. ));
  423. $element->setValue(array('bar', 'bat'));
  424. ]]>
  425. </programlisting>
  426. <para>
  427. Note that even when setting a single value, you must pass an array.
  428. </para>
  429. </sect2>
  430. <sect2 id="zend.form.standardElements.multiselect">
  431. <title>Zend_Form_Element_Multiselect</title>
  432. <para>
  433. XHTML <code>select</code> elements allow a 'multiple' attribute,
  434. indicating multiple options may be selected for submission, instead
  435. of the usual one. <code>Zend_Form_Element_Multiselect</code> extends
  436. <link linkend="zend.form.standardElements.select">Zend_Form_Element_Select</link>,
  437. and sets the <code>multiple</code> attribute to 'multiple'. Like
  438. other classes that inherit from the base
  439. <code>Zend_Form_Element_Multi</code> class, you can manipulate the
  440. options for the select using:
  441. </para>
  442. <itemizedlist>
  443. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  444. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  445. <listitem><para><code>setMultiOptions(array $options)</code>
  446. (overwrites existing options)</para></listitem>
  447. <listitem><para>getMultiOption($option)</para></listitem>
  448. <listitem><para>getMultiOptions()</para></listitem>
  449. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  450. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  451. </itemizedlist>
  452. <para>
  453. If a translation adapter is registered with the form and/or element,
  454. option values will be translated for display purposes.
  455. </para>
  456. <para>
  457. By default, this element registers an <code>InArray</code> validator
  458. which validates against the array keys of registered options. You
  459. can disable this behavior by either calling
  460. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  461. false value to the <code>registerInArrayValidator</code>
  462. configuration key.
  463. </para>
  464. </sect2>
  465. <sect2 id="zend.form.standardElements.password">
  466. <title>Zend_Form_Element_Password</title>
  467. <para>
  468. Password elements are basically normal text elements -- except that
  469. you typically do not want the submitted password displayed in error
  470. messages or the element itself when the form is re-displayed.
  471. </para>
  472. <para>
  473. <code>Zend_Form_Element_Password</code> achieves this by calling
  474. <code>setObscureValue(true)</code> on each validator (ensuring that
  475. the password is obscured in validation error messages), and using
  476. the 'formPassword' view helper (which does not display the value
  477. passed to it).
  478. </para>
  479. </sect2>
  480. <sect2 id="zend.form.standardElements.radio">
  481. <title>Zend_Form_Element_Radio</title>
  482. <para>
  483. Radio elements allow you to specify several options, of which you
  484. need a single value returned. <code>Zend_Form_Element_Radio</code>
  485. extends the base <code>Zend_Form_Element_Multi</code> class,
  486. allowing you to specify a number of options, and then uses the
  487. <code>formRadio</code> view helper to display these.
  488. </para>
  489. <para>
  490. By default, this element registers an <code>InArray</code> validator
  491. which validates against the array keys of registered options. You
  492. can disable this behavior by either calling
  493. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  494. false value to the <code>registerInArrayValidator</code>
  495. configuration key.
  496. </para>
  497. <para>
  498. Like all elements extending the Multi element base class, the
  499. following methods may be used to manipulate the radio options
  500. displayed:
  501. </para>
  502. <itemizedlist>
  503. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  504. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  505. <listitem><para><code>setMultiOptions(array $options)</code>
  506. (overwrites existing options)</para></listitem>
  507. <listitem><para>getMultiOption($option)</para></listitem>
  508. <listitem><para>getMultiOptions()</para></listitem>
  509. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  510. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  511. </itemizedlist>
  512. </sect2>
  513. <sect2 id="zend.form.standardElements.reset">
  514. <title>Zend_Form_Element_Reset</title>
  515. <para>
  516. Reset buttons are typically used to clear a form, and are not part
  517. of submitted data. However, as they serve a purpose in the display,
  518. they are included in the standard elements.
  519. </para>
  520. <para>
  521. <code>Zend_Form_Element_Reset</code> extends <link linkend="zend.form.standardElements.submit">Zend_Form_Element_Submit</link>.
  522. As such, the label is used for the button display, and will be
  523. translated if a translation adapter is present. It utilizes only the
  524. 'ViewHelper' and 'DtDdWrapper' decorators, as there should never be
  525. error messages for such elements, nor will a label be necessary.
  526. </para>
  527. </sect2>
  528. <sect2 id="zend.form.standardElements.select">
  529. <title>Zend_Form_Element_Select</title>
  530. <para>
  531. Select boxes are a common way of limiting to specific choices for a
  532. given form datum. <code>Zend_Form_Element_Select</code> allows you
  533. to generate these quickly and easily.
  534. </para>
  535. <para>
  536. By default, this element registers an <code>InArray</code> validator
  537. which validates against the array keys of registered options. You
  538. can disable this behavior by either calling
  539. <code>setRegisterInArrayValidator(false)</code>, or by passing a
  540. false value to the <code>registerInArrayValidator</code>
  541. configuration key.
  542. </para>
  543. <para>
  544. As it extends the base Multi element, the following methods may be
  545. used to manipulate the select options:
  546. </para>
  547. <itemizedlist>
  548. <listitem><para><code>addMultiOption($option, $value)</code></para></listitem>
  549. <listitem><para><code>addMultiOptions(array $options)</code></para></listitem>
  550. <listitem><para><code>setMultiOptions(array $options)</code>
  551. (overwrites existing options)</para></listitem>
  552. <listitem><para>getMultiOption($option)</para></listitem>
  553. <listitem><para>getMultiOptions()</para></listitem>
  554. <listitem><para><code>removeMultiOption($option)</code></para></listitem>
  555. <listitem><para><code>clearMultiOptions()</code></para></listitem>
  556. </itemizedlist>
  557. <para>
  558. <code>Zend_Form_Element_Select</code> uses the 'formSelect' view
  559. helper for decoration.
  560. </para>
  561. </sect2>
  562. <sect2 id="zend.form.standardElements.submit">
  563. <title>Zend_Form_Element_Submit</title>
  564. <para>
  565. Submit buttons are used to submit a form. You may use multiple
  566. submit buttons; you can use the button used to submit the form to
  567. decide what action to take with the data submitted.
  568. <code>Zend_Form_Element_Submit</code> makes this decisioning easy,
  569. by adding a <code>isChecked()</code> method; as only one button
  570. element will be submitted by the form, after populating or
  571. validating the form, you can call this method on each submit button
  572. to determine which one was used.
  573. </para>
  574. <para>
  575. <code>Zend_Form_Element_Submit</code> uses the label as the "value"
  576. of the submit button, translating it if a translation adapter is
  577. present. <code>isChecked()</code> checks the submitted value against
  578. the label in order to determine if the button was used.
  579. </para>
  580. <para>
  581. The <link linkend="zend.form.standardDecorators.viewHelper">ViewHelper</link>
  582. and <link linkend="zend.form.standardDecorators.dtDdWrapper">DtDdWrapper</link>
  583. decorators to render the element. No label decorator is used, as the
  584. button label is used when rendering the element; also, typically,
  585. you will not associate errors with a submit element.
  586. </para>
  587. </sect2>
  588. <sect2 id="zend.form.standardElements.text">
  589. <title>Zend_Form_Element_Text</title>
  590. <para>
  591. By far the most prevalent type of form element is the text element,
  592. allowing for limited text entry; it's an ideal element for most data
  593. entry. <code>Zend_Form_Element_Text</code> simply uses the
  594. 'formText' view helper to display the element.
  595. </para>
  596. </sect2>
  597. <sect2 id="zend.form.standardElements.textarea">
  598. <title>Zend_Form_Element_Textarea</title>
  599. <para>
  600. Textareas are used when large quantities of text are expected, and
  601. place no limits on the amount of text submitted (other than maximum
  602. size limits as dictated by your server or PHP).
  603. <code>Zend_Form_Element_Textarea</code> uses the 'textArea' view
  604. helper to display such elements, placing the value as the content of
  605. the element.
  606. </para>
  607. </sect2>
  608. </sect1>
  609. <!--
  610. vim:se ts=4 sw=4 tw=80 et:
  611. -->