Zend_Dojo-View-Helpers.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.dojo.view.dijit">
  4. <title>Dijit-Specific View Helpers</title>
  5. <para>
  6. From the Dojo manual: "Dijit is a widget system layered on top of
  7. dojo." Dijit includes a variety of layout and form widgets designed to
  8. provide accessibility features, localization, and standardized (and
  9. themeable) look-and-feel.
  10. </para>
  11. <para>
  12. Zend Framework ships a variety of view helpers that allow you to render
  13. and utilize dijits within your view scripts. There are three basic
  14. types:
  15. </para>
  16. <itemizedlist>
  17. <listitem>
  18. <para>
  19. <emphasis>Layout Containers</emphasis>: these are designed to be
  20. used within your view scripts or consumed by form decorators
  21. for forms, sub forms, and display groups. They wrap the various
  22. classes offerred in dijit.layout. Each dijit layout view helper
  23. expects the following arguments:
  24. </para>
  25. <itemizedlist>
  26. <listitem><para>
  27. <varname>$id</varname>: the container name or DOM ID.
  28. </para></listitem>
  29. <listitem><para>
  30. <varname>$content</varname>: the content to wrap in the
  31. layout container.
  32. </para></listitem>
  33. <listitem><para>
  34. <varname>$params</varname> (optional): dijit-specific
  35. parameters. Basically, any non-HTML attribute that can
  36. be used to configure the dijit layout container.
  37. </para></listitem>
  38. <listitem><para>
  39. <varname>$attribs</varname> (optional): any additional HTML
  40. attributes that should be used to render the container
  41. div. If the key 'id' is passed in this array, it will
  42. be used for the form element DOM id, and
  43. <varname>$id</varname> will be used for its name.
  44. </para></listitem>
  45. </itemizedlist>
  46. <para>
  47. If you pass no arguments to a dijit layout view helper, the
  48. helper itself will be returned. This allows you to capture
  49. content, which is often an easier way to pass content to the
  50. layout container. Examples of this functionality will be shown
  51. later in this section.
  52. </para>
  53. </listitem>
  54. <listitem>
  55. <para>
  56. <emphasis>Form Dijit</emphasis>: the dijit.form.Form dijit, while
  57. not completely necessary for use with dijit form elements, will
  58. ensure that if an attempt is made to submit a form that does
  59. not validate against client-side validations, submission will
  60. be halted and validation error messages raised. The form dijit
  61. view helper expects the following arguments:
  62. </para>
  63. <itemizedlist>
  64. <listitem><para>
  65. <varname>$id</varname>: the container name or DOM ID.
  66. </para></listitem>
  67. <listitem><para>
  68. <varname>$attribs</varname> (optional): any additional HTML
  69. attributes that should be used to render the container
  70. div.
  71. </para></listitem>
  72. <listitem><para>
  73. <varname>$content</varname> (optional): the content to wrap
  74. in the form. If none is passed, an empty string will be
  75. used.
  76. </para></listitem>
  77. </itemizedlist>
  78. <para>
  79. The argument order varies from the other dijits in order to
  80. keep compatibility with the standard <methodname>form()</methodname> view
  81. helper.
  82. </para>
  83. </listitem>
  84. <listitem>
  85. <para>
  86. <emphasis>Form Elements</emphasis>: these are designed to be
  87. consumed with <classname>Zend_Form</classname>, but can be used
  88. standalone within view scripts as well. Each dijit element view
  89. helper expects the following arguments:
  90. </para>
  91. <itemizedlist>
  92. <listitem><para>
  93. <varname>$id</varname>: the element name or DOM ID.
  94. </para></listitem>
  95. <listitem><para>
  96. <varname>$value</varname> (optional): the current value of
  97. the element.
  98. </para></listitem>
  99. <listitem><para>
  100. <varname>$params</varname> (optional): dijit-specific
  101. parameters. Basically, any non-HTML attribute that can
  102. be used to configure a dijit.
  103. </para></listitem>
  104. <listitem><para>
  105. <varname>$attribs</varname> (optional): any additional HTML
  106. attributes that should be used to render the dijit. If
  107. the key 'id' is passed in this array, it will be used
  108. for the form element DOM id, and <varname>$id</varname> will
  109. be used for its name.
  110. </para></listitem>
  111. </itemizedlist>
  112. <para>
  113. Some elements require more arguments; these will be noted with
  114. the individual element helper descriptions.
  115. </para>
  116. </listitem>
  117. </itemizedlist>
  118. <para>
  119. In order to utilize these view helpers, you need to register the path
  120. to the dojo view helpers with your view object.
  121. </para>
  122. <example id="zend.dojo.view.dijit.prefixpath">
  123. <title>Registering the Dojo View Helper Prefix Path</title>
  124. <programlisting language="php"><![CDATA[
  125. $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
  126. ]]></programlisting>
  127. </example>
  128. <sect3 id="zend.dojo.view.dijit.layout">
  129. <title>Dijit Layout Elements</title>
  130. <para>
  131. The dijit.layout family of elements are for creating custom,
  132. predictable layouts for your site. For any questions on general
  133. usage, <ulink
  134. url="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/layout">read
  135. more about them in the Dojo manual</ulink>.
  136. </para>
  137. <para>
  138. All dijit layout elements have the
  139. signature <command>string ($id = null, $content = '', array $params =
  140. array(), array $attribs = array())</command>. In all caess, if you
  141. pass no arguments, the helper object itself will be returned. This
  142. gives you access to the <methodname>captureStart()</methodname> and
  143. <methodname>captureEnd()</methodname> methods, which allow you to capture
  144. content instead of passing it to the layout container.
  145. </para>
  146. <itemizedlist>
  147. <listitem>
  148. <para>
  149. <emphasis>AccordionContainer</emphasis>:
  150. dijit.layout.AccordionContainer. Stack all panes together
  151. vertically; clicking on a pane titlebar will expand and
  152. display that particular pane.
  153. </para>
  154. <programlisting language="php"><![CDATA[
  155. <?php echo $view->accordionContainer(
  156. 'foo',
  157. $content,
  158. array(
  159. 'duration' => 200,
  160. ),
  161. array(
  162. 'style' => 'width: 200px; height: 300px;',
  163. ),
  164. ); ?>
  165. ]]></programlisting>
  166. </listitem>
  167. <listitem>
  168. <para>
  169. <emphasis>AccordionPane</emphasis>: dijit.layout.AccordionPane.
  170. For use within AccordionContainer.
  171. </para>
  172. <programlisting language="php"><![CDATA[
  173. <?php echo $view->accordionPane(
  174. 'foo',
  175. $content,
  176. array(
  177. 'title' => 'Pane Title',
  178. ),
  179. array(
  180. 'style' => 'background-color: lightgray;',
  181. ),
  182. ); ?>
  183. ]]></programlisting>
  184. </listitem>
  185. <listitem>
  186. <para>
  187. <emphasis>BorderContainer</emphasis>:
  188. dijit.layout.BorderContainer. Achieve layouts with
  189. optionally resizable panes such as you might see in a
  190. traditional application.
  191. </para>
  192. <programlisting language="php"><![CDATA[
  193. <?php echo $view->borderContainer(
  194. 'foo',
  195. $content,
  196. array(
  197. 'design' => 'headline',
  198. ),
  199. array(
  200. 'style' => 'width: 100%; height: 100%',
  201. ),
  202. ); ?>
  203. ]]></programlisting>
  204. </listitem>
  205. <listitem>
  206. <para>
  207. <emphasis>ContentPane</emphasis>: dijit.layout.ContentPane. Use
  208. inside any container except AccordionContainer.
  209. </para>
  210. <programlisting language="php"><![CDATA[
  211. <?php echo $view->contentPane(
  212. 'foo',
  213. $content,
  214. array(
  215. 'title' => 'Pane Title',
  216. 'region' => 'left',
  217. ),
  218. array(
  219. 'style' => 'width: 120px; background-color: lightgray;',
  220. ),
  221. ); ?>
  222. ]]></programlisting>
  223. </listitem>
  224. <listitem>
  225. <para>
  226. <emphasis>SplitContainer</emphasis>:
  227. dijit.layout.SplitContainer. Allows resizable content
  228. panes; deprecated in Dojo in favor of BorderContainer.
  229. </para>
  230. <programlisting language="php"><![CDATA[
  231. <?php echo $view->splitContainer(
  232. 'foo',
  233. $content,
  234. array(
  235. 'orientation' => 'horizontal',
  236. 'sizerWidth' => 7,
  237. 'activeSizing' => true,
  238. ),
  239. array(
  240. 'style' => 'width: 400px; height: 500px;',
  241. ),
  242. ); ?>
  243. ]]></programlisting>
  244. </listitem>
  245. <listitem>
  246. <para>
  247. <emphasis>StackContainer</emphasis>:
  248. dijit.layout.StackContainer. All panes within a
  249. StackContainer are placed in a stack; build buttons or
  250. functionality to reveal one at a time.
  251. </para>
  252. <programlisting language="php"><![CDATA[
  253. <?php echo $view->stackContainer(
  254. 'foo',
  255. $content,
  256. array(),
  257. array(
  258. 'style' => 'width: 400px; height: 500px; border: 1px;',
  259. ),
  260. ); ?>
  261. ]]></programlisting>
  262. </listitem>
  263. <listitem>
  264. <para>
  265. <emphasis>TabContainer</emphasis>:
  266. dijit.layout.TabContainer. All panes within a
  267. TabContainer are placed in a stack, with tabs positioned on
  268. one side for switching between them.
  269. </para>
  270. <programlisting language="php"><![CDATA[
  271. <?php echo $view->tabContainer(
  272. 'foo',
  273. $content,
  274. array(),
  275. array(
  276. 'style' => 'width: 400px; height: 500px; border: 1px;',
  277. ),
  278. ); ?>
  279. ]]></programlisting>
  280. </listitem>
  281. </itemizedlist>
  282. <para>
  283. The following capture methods are available for all layout
  284. containers:
  285. </para>
  286. <itemizedlist>
  287. <listitem>
  288. <para>
  289. <command>captureStart($id, array $params = array(), array $attribs =
  290. array())</command>: begin capturing content to include in a container.
  291. <varname>$params</varname> refers to the dijit params to use with
  292. the container, while <varname>$attribs</varname> refer to any
  293. general HTML attributes to use.
  294. </para>
  295. <para>
  296. Containers may be nested when capturing, <emphasis>so long
  297. as no ids are duplicated</emphasis>.
  298. </para>
  299. </listitem>
  300. <listitem>
  301. <para>
  302. <methodname>captureEnd($id)</methodname>:
  303. finish capturing content to include in a container.
  304. <varname>$id</varname> should refer to an id previously used with
  305. a <methodname>captureStart()</methodname> call. Returns a string
  306. representing the container and its contents, just as if
  307. you'd simply passed content to the helper itself.
  308. </para>
  309. </listitem>
  310. </itemizedlist>
  311. <example id="zend.dojo.view.dijit.layout.borderexample">
  312. <title>BorderContainer layout dijit example</title>
  313. <para>
  314. BorderContainers, particularly when coupled with the ability to
  315. capture content, are especially useful for achieving complex
  316. layout effects.
  317. </para>
  318. <programlisting language="php"><![CDATA[
  319. $view->borderContainer()->captureStart('masterLayout',
  320. array('design' => 'headline'));
  321. echo $view->contentPane(
  322. 'menuPane',
  323. 'This is the menu pane',
  324. array('region' => 'top'),
  325. array('style' => 'background-color: darkblue;')
  326. );
  327. echo $view->contentPane(
  328. 'navPane',
  329. 'This is the navigation pane',
  330. array('region' => 'left'),
  331. array('style' => 'width: 200px; background-color: lightblue;')
  332. );
  333. echo $view->contentPane(
  334. 'mainPane',
  335. 'This is the main content pane area',
  336. array('region' => 'center'),
  337. array('style' => 'background-color: white;')
  338. );
  339. echo $view->contentPane(
  340. 'statusPane',
  341. 'Status area',
  342. array('region' => 'bottom'),
  343. array('style' => 'background-color: lightgray;')
  344. );
  345. echo $view->borderContainer()->captureEnd('masterLayout');
  346. ]]></programlisting>
  347. </example>
  348. </sect3>
  349. <sect3 id="zend.dojo.view.dijit.form">
  350. <title>Dijit Form Elements</title>
  351. <para>
  352. Dojo's form validation and input dijits are in the dijit.form tree.
  353. For more information on general usage of these elements, as well as
  354. accepted parameters, please <ulink
  355. url="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-specialized-input">visit
  356. the dijit.form documentation</ulink>.
  357. </para>
  358. <para>
  359. The following dijit form elements are available in Zend Framework.
  360. Except where noted, all have the signature <command>string ($id,
  361. $value = '', array $params = array(), array $attribs =
  362. array())</command>.
  363. </para>
  364. <itemizedlist>
  365. <listitem>
  366. <para>
  367. <emphasis>Button</emphasis>: dijit.form.Button. Display a
  368. form button.
  369. </para>
  370. <programlisting language="php"><![CDATA[
  371. <?php echo $view->button(
  372. 'foo',
  373. 'Show Me!',
  374. array('iconClass' => 'myButtons'),
  375. ); ?>
  376. ]]></programlisting>
  377. </listitem>
  378. <listitem>
  379. <para>
  380. <emphasis>CheckBox</emphasis>:
  381. dijit.form.CheckBox. Display a checkbox. Accepts an
  382. optional fifth argument, the array
  383. <varname>$checkedOptions</varname>, which may contain either:
  384. </para>
  385. <itemizedlist>
  386. <listitem><para>
  387. an indexed array with two values, a checked value
  388. and unchecked value, in that order; or
  389. </para></listitem>
  390. <listitem><para>
  391. an associative array with the keys 'checkedValue'
  392. and 'unCheckedValue'.
  393. </para></listitem>
  394. </itemizedlist>
  395. <para>
  396. If <varname>$checkedOptions</varname> is not provided, 1 and 0
  397. are assumed.
  398. </para>
  399. <programlisting language="php"><![CDATA[
  400. <?php echo $view->checkBox(
  401. 'foo',
  402. 'bar',
  403. array(),
  404. array(),
  405. array('checkedValue' => 'foo', 'unCheckedValue' => 'bar')
  406. ); ?>
  407. ]]></programlisting>
  408. </listitem>
  409. <listitem>
  410. <para>
  411. <emphasis>ComboBox</emphasis>:
  412. dijit.layout.ComboBox. ComboBoxes are a hybrid between a
  413. select and a text box with autocompletion. The key
  414. difference is that you may type an option that is not in
  415. the list of available options, and it will still consider
  416. it valid input. It accepts an optional fifth argument, an
  417. associative array <varname>$options</varname>; if provided,
  418. ComboBox will be rendered as a <emphasis>select</emphasis>. Note
  419. also that the <emphasis>label values</emphasis> of the
  420. <varname>$options</varname> array will be returned in the form --
  421. not the values themselves.
  422. </para>
  423. <para>
  424. Alternately, you may pass information regarding a dojo.data
  425. datastore to use with the element. If provided, the
  426. ComboBox will be rendered as a text <emphasis>input</emphasis>, and
  427. will pull its options via that datastore.
  428. </para>
  429. <para>
  430. To specify a datastore, provide one of the following
  431. <varname>$params</varname> key combinations:
  432. </para>
  433. <itemizedlist>
  434. <listitem>
  435. <para>
  436. The key 'store', with an array value; the array
  437. should contain the keys:
  438. </para>
  439. <itemizedlist>
  440. <listitem><para>
  441. <emphasis>store</emphasis>: the name of the
  442. javascript variable representing the datastore
  443. (this could be the name you would like for it
  444. to use).
  445. </para></listitem>
  446. <listitem><para>
  447. <emphasis>type</emphasis>: the datastore type
  448. to use; e.g., 'dojo.data.ItemFileReadStore'.
  449. </para></listitem>
  450. <listitem><para>
  451. <emphasis>params</emphasis> (optional): an
  452. associative array of key/value pairs to use to
  453. configure the datastore. The 'url' param is a
  454. typical example.
  455. </para></listitem>
  456. </itemizedlist>
  457. </listitem>
  458. <listitem>
  459. <para>
  460. The keys:
  461. </para>
  462. <itemizedlist>
  463. <listitem><para>
  464. <emphasis>store</emphasis>: a string indicating
  465. the datastore name to use.
  466. </para></listitem>
  467. <listitem><para>
  468. <emphasis>storeType</emphasis>: a string indicating
  469. the datastore dojo.data type to use (e.g.,
  470. 'dojo.data.ItemFileReadStore').
  471. </para></listitem>
  472. <listitem><para>
  473. <emphasis>storeParams</emphasis>: an
  474. associative array of key/value pairs with which
  475. to configure the datastore.
  476. </para></listitem>
  477. </itemizedlist>
  478. </listitem>
  479. </itemizedlist>
  480. <programlisting language="php"><![CDATA[
  481. // As a select element:
  482. echo $view->comboBox(
  483. 'foo',
  484. 'bar',
  485. array(
  486. 'autocomplete' => false,
  487. ),
  488. array(),
  489. array(
  490. 'foo' => 'Foo',
  491. 'bar' => 'Bar',
  492. 'baz' => 'Baz',
  493. )
  494. );
  495. // As a dojo.data-enabled element:
  496. echo $view->comboBox(
  497. 'foo',
  498. 'bar',
  499. array(
  500. 'autocomplete' => false,
  501. 'store' => 'stateStore',
  502. 'storeType' => 'dojo.data.ItemFileReadStore',
  503. 'storeParams' => array('url' => '/js/states.json'),
  504. ),
  505. );
  506. ]]></programlisting>
  507. </listitem>
  508. <listitem>
  509. <para>
  510. <emphasis>CurrencyTextBox</emphasis>:
  511. dijit.form.CurrencyTextBox. Inherits from
  512. ValidationTextBox, and provides client-side validation of
  513. currency. It expects that the dijit parameter 'currency'
  514. will be provided with an appropriate 3-character currency
  515. code. You may also specify any dijit parameters valid for
  516. ValidationTextBox and TextBox.
  517. </para>
  518. <programlisting language="php"><![CDATA[
  519. echo $view->currencyTextBox(
  520. 'foo',
  521. '$25.00',
  522. array('currency' => 'USD'),
  523. array('maxlength' => 20)
  524. );
  525. ]]></programlisting>
  526. <note>
  527. <title>Issues with Builds</title>
  528. <para>
  529. There are currently <ulink
  530. url="http://trac.dojotoolkit.org/ticket/7183">known
  531. issues with using CurrencyTextBox with build
  532. layers</ulink>. A known work-around is to ensure that
  533. your document's Content-Type http-equiv meta tag sets the
  534. character set to utf-8, which you can do by calling:
  535. </para>
  536. <programlisting language="php"><![CDATA[
  537. $view->headMeta()->appendHttpEquiv('Content-Type',
  538. 'text/html; charset=utf-8');
  539. ]]></programlisting>
  540. <para>
  541. This will mean, of course, that you will need to ensure
  542. that the <methodname>headMeta()</methodname> placeholder is echoed
  543. in your layout script.
  544. </para>
  545. </note>
  546. </listitem>
  547. <listitem>
  548. <para>
  549. <emphasis>DateTextBox</emphasis>:
  550. dijit.form.DateTextBox. Inherits from
  551. ValidationTextBox, and provides both client-side validation of
  552. dates, as well as a dropdown calendar from which to select a date.
  553. You may specify any dijit parameters available to
  554. ValidationTextBox or TextBox.
  555. </para>
  556. <programlisting language="php"><![CDATA[
  557. echo $view->dateTextBox(
  558. 'foo',
  559. '2008-07-11',
  560. array('required' => true)
  561. );
  562. ]]></programlisting>
  563. </listitem>
  564. <listitem>
  565. <para>
  566. <emphasis>Editor</emphasis>: dijit.Editor. Provides a
  567. WYSIWYG editor via which users may create or edit content.
  568. <command>dijit.Editor</command> is a pluggable, extensible editor
  569. with a variety of parameters you can utilize for customization; see <ulink
  570. url="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/advanced-editing-and-display/editor-rich-text">the
  571. dijit.Editor documentation</ulink> for more details.
  572. </para>
  573. <programlisting language="php"><![CDATA[
  574. echo $view->editor('foo');
  575. ]]></programlisting>
  576. <note>
  577. <title>Editor Dijit uses div by default</title>
  578. <para>
  579. The Editor dijit uses an <acronym>HTML</acronym> <acronym>DIV</acronym> by
  580. default. The <classname>dijit._editor.RichText</classname> <ulink
  581. url="http://api.dojotoolkit.org/jsdoc/HEAD/dijit._editor.RichText">documentation</ulink>
  582. indicates that having it built on an HTML <acronym>TEXTAREA</acronym> can
  583. potentially have security implications.
  584. </para>
  585. <para>
  586. In order to allow graceful degradation in environments where Javascript is
  587. unavailable, <classname>Zend_Dojo_View_Helper_Editor</classname> also wraps
  588. a <acronym>textarea</acronym> within a <acronym>noscript</acronym> tag; the
  589. content of this <acronym>textarea</acronym> will be properly escaped to
  590. avoid security vulnerability vectors.
  591. </para>
  592. </note>
  593. </listitem>
  594. <listitem>
  595. <para>
  596. <emphasis>FilteringSelect</emphasis>:
  597. dijit.form.FilteringSelect. Similar to ComboBox, this is a
  598. select/text hybrid that can either render a provided list
  599. of options or those fetched via a dojo.data datastore.
  600. Unlike ComboBox, however, FilteringSelect does not allow
  601. typing in an option not in its list. Additionally, it
  602. operates like a standard select in that the option values,
  603. not the labels, are returned when the form is submitted.
  604. </para>
  605. <para>
  606. Please see the information above on ComboBox for examples
  607. and available options for defining datastores.
  608. </para>
  609. </listitem>
  610. <listitem>
  611. <para>
  612. <emphasis>HorizontalSlider</emphasis> and
  613. <emphasis>VerticalSlider</emphasis>:
  614. dijit.form.HorizontalSlider and dijit.form.VerticalSlider.
  615. Sliders allow are UI widgets for selecting numbers in a
  616. given range; these are horizontal and vertical variants.
  617. </para>
  618. <para>
  619. At their most basic, they require the dijit parameters
  620. 'minimum', 'maximum', and 'discreteValues'. These define
  621. the range of values. Other common options are:
  622. </para>
  623. <itemizedlist>
  624. <listitem><para>
  625. 'intermediateChanges' can be set to indicate whether or not
  626. to fire onChange events while the handle is being dragged.
  627. </para></listitem>
  628. <listitem><para>
  629. 'clickSelect' can be set to allow clicking a location
  630. on the slider to set the value.
  631. </para></listitem>
  632. <listitem><para>
  633. 'pageIncrement' can specify the value by which to
  634. increase/decrease when pageUp and pageDown are used.
  635. </para></listitem>
  636. <listitem><para>
  637. 'showButtons' can be set to allow displaying buttons on
  638. either end of the slider for manipulating the value.
  639. </para></listitem>
  640. </itemizedlist>
  641. <para>
  642. The Zend Framework implementation creates a hidden element
  643. to store the value of the slider.
  644. </para>
  645. <para>
  646. You may optionally desire to show a rule or labels for the
  647. slider. To do so, you will assign one or more of the dijit
  648. params 'topDecoration' and/or 'bottomDecoration'
  649. (HorizontalSlider) or 'leftDecoration' and/or
  650. 'rightDecoration' (VerticalSlider). Each of these expects
  651. the following options:
  652. </para>
  653. <itemizedlist>
  654. <listitem><para>
  655. <emphasis>container</emphasis>: name of the container.
  656. </para></listitem>
  657. <listitem><para>
  658. <emphasis>labels</emphasis> (optional): an array of
  659. labels to utilize. Use empty strings on either end to
  660. provide labels for inner values only. Required when
  661. specifying one of the 'Labels' dijit variants.
  662. </para></listitem>
  663. <listitem><para>
  664. <emphasis>dijit</emphasis> (optional): one of
  665. HorizontalRule, HorizontalRuleLabels, VerticalRule, or
  666. VerticalRuleLabels, Defaults to one of the Rule dijits.
  667. </para></listitem>
  668. <listitem>
  669. <para>
  670. <emphasis>params</emphasis> (optional): dijit params
  671. for configuring the Rule dijit in use. Parameters
  672. specific to these dijits include:
  673. </para>
  674. <itemizedlist>
  675. <listitem><para>
  676. <emphasis>container</emphasis> (optional):
  677. array of parameters and attributes for the rule
  678. container.
  679. </para></listitem>
  680. <listitem><para>
  681. <emphasis>labels</emphasis> (optional):
  682. array of parameters and attributes for the
  683. labels list container.
  684. </para></listitem>
  685. </itemizedlist>
  686. </listitem>
  687. <listitem><para>
  688. <emphasis>attribs</emphasis> (optional): HTML
  689. attributes to use with the rules/labels. This should
  690. follow the <property>params</property> option format and be an
  691. associative array with the keys 'container' and
  692. 'labels'.
  693. </para></listitem>
  694. </itemizedlist>
  695. <programlisting language="php"><![CDATA[
  696. echo $view->horizontalSlider(
  697. 'foo',
  698. 1,
  699. array(
  700. 'minimum' => -10,
  701. 'maximum' => 10,
  702. 'discreteValues' => 11,
  703. 'intermediateChanges' => true,
  704. 'showButtons' => true,
  705. 'topDecoration' => array(
  706. 'container' => 'topContainer'
  707. 'dijit' => 'HorizontalRuleLabels',
  708. 'labels' => array(
  709. ' ',
  710. '20%',
  711. '40%',
  712. '60%',
  713. '80%',
  714. ' ',
  715. ),
  716. 'params' => array(
  717. 'container' => array(
  718. 'style' => 'height:1.2em; font-size=75%;color:gray;',
  719. ),
  720. 'labels' => array(
  721. 'style' => 'height:1em; font-size=75%;color:gray;',
  722. ),
  723. ),
  724. ),
  725. 'bottomDecoration' => array(
  726. 'container' => 'bottomContainer'
  727. 'labels' => array(
  728. '0%',
  729. '50%',
  730. '100%',
  731. ),
  732. 'params' => array(
  733. 'container' => array(
  734. 'style' => 'height:1.2em; font-size=75%;color:gray;',
  735. ),
  736. 'labels' => array(
  737. 'style' => 'height:1em; font-size=75%;color:gray;',
  738. ),
  739. ),
  740. ),
  741. )
  742. );
  743. ]]></programlisting>
  744. </listitem>
  745. <listitem>
  746. <para>
  747. <emphasis>NumberSpinner</emphasis>:
  748. dijit.form.NumberSpinner. Text box for numeric entry, with
  749. buttons for incrementing and decrementing.
  750. </para>
  751. <para>
  752. Expects either an associative array for the dijit parameter
  753. 'constraints', or simply the keys 'min', 'max', and
  754. 'places' (these would be the expected entries of the
  755. constraints parameter as well). 'places' can be used to
  756. indicate how much the number spinner will increment and
  757. decrement.
  758. </para>
  759. <programlisting language="php"><![CDATA[
  760. echo $view->numberSpinner(
  761. 'foo',
  762. 5,
  763. array(
  764. 'min' => -10,
  765. 'max' => 10,
  766. 'places' => 2,
  767. ),
  768. array(
  769. 'maxlenth' => 3,
  770. )
  771. );
  772. ]]></programlisting>
  773. </listitem>
  774. <listitem>
  775. <para>
  776. <emphasis>NumberTextBox</emphasis>:
  777. dijit.form.NumberTextBox. NumberTextBox provides the
  778. ability to format and display number entries in a localized
  779. fashion, as well as validate numerical entries, optionally
  780. against given constraints.
  781. </para>
  782. <programlisting language="php"><![CDATA[
  783. echo $view->numberTextBox(
  784. 'foo',
  785. 5,
  786. array(
  787. 'places' => 4,
  788. 'type' => 'percent',
  789. ),
  790. array(
  791. 'maxlength' => 20,
  792. )
  793. );
  794. ]]></programlisting>
  795. </listitem>
  796. <listitem>
  797. <para>
  798. <emphasis>PasswordTextBox</emphasis>:
  799. dijit.form.ValidationTextBox tied to a password input.
  800. PasswordTextBox provides the
  801. ability to create password input that adheres to the current
  802. dijit theme, as well as allow for client-side validation.
  803. </para>
  804. <programlisting language="php"><![CDATA[
  805. echo $view->passwordTextBox(
  806. 'foo',
  807. '',
  808. array(
  809. 'required' => true,
  810. ),
  811. array(
  812. 'maxlength' => 20,
  813. )
  814. );
  815. ]]></programlisting>
  816. </listitem>
  817. <listitem>
  818. <para>
  819. <emphasis>RadioButton</emphasis>: dijit.form.RadioButton. A
  820. set of options from which only one may be selected. This
  821. behaves in every way like a regular radio, but has a
  822. look-and-feel consistent with other dijits.
  823. </para>
  824. <para>
  825. RadioButton accepts an optional fifth argument,
  826. <varname>$options</varname>, an associative array of value/label
  827. pairs used as the radio options. You may also pass these as
  828. the <varname>$attribs</varname> key <property>options</property>.
  829. </para>
  830. <programlisting language="php"><![CDATA[
  831. echo $view->radioButton(
  832. 'foo',
  833. 'bar',
  834. array(),
  835. array(),
  836. array(
  837. 'foo' => 'Foo',
  838. 'bar' => 'Bar',
  839. 'baz' => 'Baz',
  840. )
  841. );
  842. ]]></programlisting>
  843. </listitem>
  844. <listitem>
  845. <para>
  846. <emphasis>SimpleTextarea</emphasis>: dijit.form.SimpleTextarea.
  847. These act like normal textareas, but are styled using the
  848. current dijit theme. You do not need to specify either the
  849. rows or columns attributes; use <property>ems</property> or
  850. percentages for the width and height, instead.
  851. </para>
  852. <programlisting language="php"><![CDATA[
  853. echo $view->simpleTextarea(
  854. 'foo',
  855. 'Start writing here...',
  856. array(),
  857. array('style' => 'width: 90%; height: 5ems;')
  858. );
  859. ]]></programlisting>
  860. </listitem>
  861. <listitem>
  862. <para>
  863. <emphasis>SubmitButton</emphasis>: a dijit.form.Button tied
  864. to a submit input element. See the Button view helper for
  865. more details; the key difference is that this button can
  866. submit a form.
  867. </para>
  868. </listitem>
  869. <listitem>
  870. <para>
  871. <emphasis>Textarea</emphasis>: dijit.form.Textarea. These
  872. act like normal textareas, except that instead of having a
  873. set number of rows, they expand as the user types. The
  874. width should be specified via a style setting.
  875. </para>
  876. <programlisting language="php"><![CDATA[
  877. echo $view->textarea(
  878. 'foo',
  879. 'Start writing here...',
  880. array(),
  881. array('style' => 'width: 300px;')
  882. );
  883. ]]></programlisting>
  884. </listitem>
  885. <listitem>
  886. <para>
  887. <emphasis>TextBox</emphasis>: dijit.form.TextBox. This
  888. element is primarily present to provide a common
  889. look-and-feel between various dijit elements, and to
  890. provide base functionality for the other TextBox-derived
  891. classes (ValidationTextBox, NumberTextBox, CurrencyTextBox,
  892. DateTextBox, and TimeTextBox).
  893. </para>
  894. <para>
  895. Common dijit parameter flags include 'lowercase' (cast to
  896. lowercase), 'uppercase' (cast to UPPERCASE), 'propercase'
  897. (cast to Proper Case), and trim (trim leading and trailing
  898. whitespace); all accept boolean values. Additionally, you
  899. may specifiy the parameters 'size' and 'maxLength'.
  900. </para>
  901. <programlisting language="php"><![CDATA[
  902. echo $view->textBox(
  903. 'foo',
  904. 'some text',
  905. array(
  906. 'trim' => true,
  907. 'propercase' => true,
  908. 'maxLength' => 20,
  909. ),
  910. array(
  911. 'size' => 20,
  912. )
  913. );
  914. ]]></programlisting>
  915. </listitem>
  916. <listitem>
  917. <para>
  918. <emphasis>TimeTextBox</emphasis>: dijit.form.TimeTextBox.
  919. Also in the TextBox family, TimeTextBox provides a
  920. scrollable drop down selection of times from which a user
  921. may select. Dijit parameters allow you to specify the time
  922. increments available in the select as well as the visible
  923. range of times available.
  924. </para>
  925. <programlisting language="php"><![CDATA[
  926. echo $view->timeTextBox(
  927. 'foo',
  928. '',
  929. array(
  930. 'am.pm' => true,
  931. 'visibleIncrement' => 'T00:05:00', // 5-minute increments
  932. 'visibleRange' => 'T02:00:00', // show 2 hours of increments
  933. ),
  934. array(
  935. 'size' => 20,
  936. )
  937. );
  938. ]]></programlisting>
  939. </listitem>
  940. <listitem>
  941. <para>
  942. <emphasis>ValidationTextBox</emphasis>:
  943. dijit.form.ValidateTextBox. Provide client-side validations
  944. for a text element. Inherits from TextBox.
  945. </para>
  946. <para>
  947. Common dijit parameters include:
  948. </para>
  949. <itemizedlist>
  950. <listitem><para>
  951. <emphasis>invalidMessage</emphasis>: a message to
  952. display when an invalid entry is detected.
  953. </para></listitem>
  954. <listitem><para>
  955. <emphasis>promptMessage</emphasis>: a tooltip help
  956. message to use.
  957. </para></listitem>
  958. <listitem><para>
  959. <emphasis>regExp</emphasis>: a regular expression to
  960. use to validate the text. Regular expression does not
  961. require boundary markers.
  962. </para></listitem>
  963. <listitem><para>
  964. <emphasis>required</emphasis>: whether or not the
  965. element is required. If so, and the element is embedded
  966. in a dijit.form.Form, it will be flagged as invalid and
  967. prevent submission.
  968. </para></listitem>
  969. </itemizedlist>
  970. <programlisting language="php"><![CDATA[
  971. echo $view->validationTextBox(
  972. 'foo',
  973. '',
  974. array(
  975. 'required' => true,
  976. 'regExp' => '[\w]+',
  977. 'invalidMessage' => 'No spaces or non-word characters allowed',
  978. 'promptMessage' => 'Single word consisting of alphanumeric ' .
  979. 'characters and underscores only',
  980. ),
  981. array(
  982. 'maxlength' => 20,
  983. )
  984. );
  985. ]]></programlisting>
  986. </listitem>
  987. </itemizedlist>
  988. </sect3>
  989. <sect3 id="zend.dojo.view.dijit.custom">
  990. <title>Custom Dijits</title>
  991. <para>
  992. If you delve into Dojo much at all, you'll find yourself writing
  993. custom dijits, or using experimental dijits from Dojox. While Zend
  994. Framework cannot support every dijit directly, it does provide some
  995. rudimentary support for arbitrary dijit types via the
  996. <classname>CustomDijit</classname> view helper.
  997. </para>
  998. <para>
  999. The <classname>CustomDijit</classname> view helper's <acronym>API</acronym> is exactly
  1000. that of any other dijit, with one major difference: the third "params"
  1001. argument <emphasis>must</emphasis> contain the attribute "dojotype".
  1002. The value of this attribute should be the Dijit class you plan to
  1003. use.
  1004. </para>
  1005. <para>
  1006. <classname>CustomDijit</classname> extends the base
  1007. <classname>DijitContainer</classname> view helper, which also allows it to
  1008. capture content (using the
  1009. <methodname>captureStart()</methodname>/<methodname>captureEnd()</methodname> pair of
  1010. methods). <methodname>captureStart()</methodname> also expects that you pass the
  1011. "dojoType" attribute to its "params" argument.
  1012. </para>
  1013. <example id="zend.dojo.view.dijit.custom.example">
  1014. <title>Using CustomDijit to render a dojox.layout.ContentPane</title>
  1015. <para>
  1016. <command>dojox.layout.ContentPane</command> is a next-generation
  1017. iteration of <command>dijit.layout.ContentPane</command>, and provides
  1018. a superset of that class's capabilities. Until it's
  1019. functionality stabilizes, it will continue to live in Dojox.
  1020. However, if you want to use it in Zend Framework today, you can,
  1021. using the <classname>CustomDijit</classname> view helper.
  1022. </para>
  1023. <para>
  1024. At its most basic, you can do the following:
  1025. </para>
  1026. <programlisting language="php"><![CDATA[
  1027. <?php echo $this->customDijit(
  1028. 'foo',
  1029. $content,
  1030. array(
  1031. 'dojoType' => 'dojox.layout.ContentPane',
  1032. 'title' => 'Custom pane',
  1033. 'region' => 'center'
  1034. )
  1035. ); ?>
  1036. ]]></programlisting>
  1037. <para>
  1038. If you wanted to capture content instead, simply use the
  1039. <methodname>captureStart()</methodname> method, and pass the "dojoType" to
  1040. the "params" argument:
  1041. </para>
  1042. <programlisting language="php"><![CDATA[
  1043. <?php $this->customDijit()->captureStart(
  1044. 'foo',
  1045. array(
  1046. 'dojoType' => 'dojox.layout.ContentPane',
  1047. 'title' => 'Custom pane',
  1048. 'region' => 'center'
  1049. )
  1050. ); ?>
  1051. This is the content of the pane
  1052. <?php echo $this->customDijit()->captureEnd('foo'); ?>
  1053. ]]></programlisting>
  1054. <para>
  1055. You can also extend <classname>CustomDijit</classname> easily to create
  1056. support for your own custom dijits. As an example, if you
  1057. extended <command>dijit.layout.ContentPane</command> to create your
  1058. own <command>foo.ContentPane</command> class, you could create the
  1059. following helper to support it:
  1060. </para>
  1061. <programlisting language="php"><![CDATA[
  1062. class My_View_Helper_FooContentPane
  1063. extends Zend_Dojo_View_Helper_CustomDijit
  1064. {
  1065. protected $_defaultDojoType = 'foo.ContentPane';
  1066. public function fooContentPane(
  1067. $id = null, $value = null,
  1068. array $params = array(), array $attribs = array()
  1069. ) {
  1070. return $this->customDijit($id, $value, $params, $attribs);
  1071. }
  1072. }
  1073. ]]></programlisting>
  1074. <para>
  1075. As long as your custom dijit follows the same basic <acronym>API</acronym> as
  1076. official dijits, using or extending <classname>CustomDijit</classname>
  1077. should work correctly.
  1078. </para>
  1079. </example>
  1080. </sect3>
  1081. </sect2>
  1082. <!--
  1083. vim:se ts=4 sw=4 et:
  1084. -->