<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://docs.joomla.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;feed=atom&amp;action=history</id>
		<title>Creating a modal form field - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;action=history"/>
		<updated>2013-05-25T18:35:33Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.3</generator>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=86209&amp;oldid=prev</id>
		<title>Wilsonge: Remove 1.6 and 1.7 tags</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=86209&amp;oldid=prev"/>
				<updated>2013-04-29T22:37:17Z</updated>
		
		<summary type="html">&lt;p&gt;Remove 1.6 and 1.7 tags&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 22:37, 29 April 2013&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{{version|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;1.6,1.7,&lt;/del&gt;2.5}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{{version|2.5}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article modal in com_content).&amp;#160; In this case, the form field will be added to the default.xml of a view so that the field/value pair will be added to the menu item URL.&amp;#160; For our example, assume we have a component named com_library, which includes views for &amp;quot;books&amp;quot; and &amp;quot;book&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article modal in com_content).&amp;#160; In this case, the form field will be added to the default.xml of a view so that the field/value pair will be added to the menu item URL.&amp;#160; For our example, assume we have a component named com_library, which includes views for &amp;quot;books&amp;quot; and &amp;quot;book&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 233:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 233:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[User:radiant_tech|Denise McLaurin]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[User:radiant_tech|Denise McLaurin]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;noinclude&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Development]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Development]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Component Development]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Component Development]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Form fields]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Form fields]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Joomla! &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;1&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;6&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Joomla! &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;2&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;5&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[Category:Joomla! 1.7]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/noinclude&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Wilsonge</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=81640&amp;oldid=prev</id>
		<title>Wilsonge at 11:21, 19 February 2013</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=81640&amp;oldid=prev"/>
				<updated>2013-02-19T11:21:05Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 11:21, 19 February 2013&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;{{version|1.6,1.7,2.5}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article modal in com_content).&amp;#160; In this case, the form field will be added to the default.xml of a view so that the field/value pair will be added to the menu item URL.&amp;#160; For our example, assume we have a component named com_library, which includes views for &amp;quot;books&amp;quot; and &amp;quot;book&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article modal in com_content).&amp;#160; In this case, the form field will be added to the default.xml of a view so that the field/value pair will be added to the menu item URL.&amp;#160; For our example, assume we have a component named com_library, which includes views for &amp;quot;books&amp;quot; and &amp;quot;book&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;{{JVer|1.6}} {{JVer|1.7}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Add modal form field to XML file ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Add modal form field to XML file ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Wilsonge</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=63205&amp;oldid=prev</id>
		<title>Mvangeest: moved How to create a modal form field in 1.6/1.7 to Creating a modal form field: Adapted page title to the continuous tense used in most tutorial titles</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=63205&amp;oldid=prev"/>
				<updated>2011-11-26T13:54:53Z</updated>
		
		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/How_to_create_a_modal_form_field_in_1.6/1.7&quot; class=&quot;mw-redirect&quot; title=&quot;How to create a modal form field in 1.6/1.7&quot;&gt;How to create a modal form field in 1.6/1.7&lt;/a&gt; to &lt;a href=&quot;/Creating_a_modal_form_field&quot; title=&quot;Creating a modal form field&quot;&gt;Creating a modal form field&lt;/a&gt;: Adapted page title to the continuous tense used in most tutorial titles&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 13:54, 26 November 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mvangeest</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=62674&amp;oldid=prev</id>
		<title>Radiant tech: Created page with &quot;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article mo...&quot;</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Creating_a_modal_form_field&amp;diff=62674&amp;oldid=prev"/>
				<updated>2011-10-19T12:43:06Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article mo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This tutorial will demonstrate how to create a custom form field that will open a list view in a modal window for the selection of a single item (similar to the Select Article modal in com_content).  In this case, the form field will be added to the default.xml of a view so that the field/value pair will be added to the menu item URL.  For our example, assume we have a component named com_library, which includes views for &amp;quot;books&amp;quot; and &amp;quot;book&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{JVer|1.6}} {{JVer|1.7}}&lt;br /&gt;
&lt;br /&gt;
== Add modal form field to XML file ==&lt;br /&gt;
Edit '''''/components/com_library/views/book/default.xml''''' and add the new field and its attributes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fields name=&amp;quot;request&amp;quot; addfieldpath=&amp;quot;administrator/components/com_library/models/fields&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset name=&amp;quot;request&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;field &lt;br /&gt;
			name=&amp;quot;id&amp;quot; &lt;br /&gt;
			type=&amp;quot;modal_book&amp;quot; &lt;br /&gt;
			label=&amp;quot;COM_LIBRARY_BOOK_FIELD_ID_LABEL&amp;quot; &lt;br /&gt;
			description=&amp;quot;COM_LIBRARY_BOOK_FIELD_ID_DESC&amp;quot;&lt;br /&gt;
			required=&amp;quot;true&amp;quot;&lt;br /&gt;
		/&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/fields&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Notice that in both the &amp;quot;fields&amp;quot; and &amp;quot;fieldset&amp;quot; declarations, we've included '''name=&amp;quot;request&amp;quot;'''.  This tells the menu item to add the field name and its value to the URL.  The custom type as been identified as '''modal_book''' and we've given a path where the class definition for this type can be found with '''addfieldpath'''.  &lt;br /&gt;
&lt;br /&gt;
== Create custom form field class ==&lt;br /&gt;
Create the new file '''''administrator/components/com_library/models/fields/modal/book.php'''''.  This file will define the JFormFieldModal_Book class which extends the [http://docs.joomla.org/JFormField/1.6 JFormField] class.  More information on custom form fields can also be found at [http://docs.joomla.org/Creating_a_custom_form_field_type Creating a custom form field type].&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 // No direct access&lt;br /&gt;
 defined('_JEXEC') or die('Restricted access');&lt;br /&gt;
 &lt;br /&gt;
 jimport('joomla.form.formfield');&lt;br /&gt;
 &lt;br /&gt;
 /**&lt;br /&gt;
  * Book form field class&lt;br /&gt;
  */&lt;br /&gt;
 class JFormFieldModal_Book extends JFormField&lt;br /&gt;
 {&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * field type&lt;br /&gt;
 	 * @var string&lt;br /&gt;
 	 */&lt;br /&gt;
 	protected $type = 'Modal_Book';&lt;br /&gt;
 	&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Override getInput() method ==&lt;br /&gt;
Next, we'll override the [http://docs.joomla.org/JFormField::getInput/1.6 getInput method] of the parent class.  This method builds the HTML for the input field.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  /**&lt;br /&gt;
   * Method to get the field input markup&lt;br /&gt;
   */&lt;br /&gt;
  protected function getInput()&lt;br /&gt;
  {&lt;br /&gt;
	  // Load modal behavior&lt;br /&gt;
	  JHtml::_('behavior.modal', 'a.modal');&lt;br /&gt;
	  &lt;br /&gt;
	  // Build the script&lt;br /&gt;
	  $script = array();&lt;br /&gt;
	  $script[] = '    function jSelectBook_'.$this-&amp;gt;id.'(id, title, object) {';&lt;br /&gt;
	  $script[] = '        document.id(&amp;quot;'.$this-&amp;gt;id.'_id&amp;quot;).value = id;';&lt;br /&gt;
	  $script[] = '        document.id(&amp;quot;'.$this-&amp;gt;id.'_name&amp;quot;).value = title;';&lt;br /&gt;
	  $script[] = '        SqueezeBox.close();';&lt;br /&gt;
	  $script[] = '    }';&lt;br /&gt;
	  &lt;br /&gt;
	  // Add to document head&lt;br /&gt;
	  JFactory::getDocument()-&amp;gt;addScriptDeclaration(implode(&amp;quot;\n&amp;quot;, $script));&lt;br /&gt;
	  &lt;br /&gt;
	  // Setup variables for display&lt;br /&gt;
	  $html = array();&lt;br /&gt;
	  $link = 'index.php?option=com_library&amp;amp;amp;view=books&amp;amp;amp;layout=modal'.&lt;br /&gt;
                  '&amp;amp;amp;tmpl=component&amp;amp;amp;function=jSelectBook_'.$this-&amp;gt;id;&lt;br /&gt;
	  &lt;br /&gt;
	  $db = JFactory::getDbo();&lt;br /&gt;
	  $query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
	  $query-&amp;gt;select('title');&lt;br /&gt;
	  $query-&amp;gt;from('#__books');&lt;br /&gt;
	  $query-&amp;gt;where('id='.(int)$this-&amp;gt;value);&lt;br /&gt;
	  $db-&amp;gt;setQuery($query);&lt;br /&gt;
	  if (!$title = $db-&amp;gt;loadResult()) {&lt;br /&gt;
		  JError::raiseWarning(500, $db-&amp;gt;getErrorMsg());&lt;br /&gt;
	  }&lt;br /&gt;
	  if (empty($title)) {&lt;br /&gt;
		  $title = JText::_('COM_LIBRARY_FIELD_SELECT_BOOK');&lt;br /&gt;
	  }&lt;br /&gt;
	  $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');&lt;br /&gt;
	  &lt;br /&gt;
	  // The current book input field&lt;br /&gt;
	  $html[] = '&amp;lt;div class=&amp;quot;fltlft&amp;quot;&amp;gt;';&lt;br /&gt;
	  $html[] = '  &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;'.$this-&amp;gt;id.'_name&amp;quot; value=&amp;quot;'.$title.'&amp;quot; disabled=&amp;quot;disabled&amp;quot; size=&amp;quot;35&amp;quot; /&amp;gt;';&lt;br /&gt;
	  $html[] = '&amp;lt;/div&amp;gt;';&lt;br /&gt;
	  &lt;br /&gt;
	  // The book select button&lt;br /&gt;
	  $html[] = '&amp;lt;div class=&amp;quot;button2-left&amp;quot;&amp;gt;';&lt;br /&gt;
	  $html[] = '  &amp;lt;div class=&amp;quot;blank&amp;quot;&amp;gt;';&lt;br /&gt;
	  $html[] = '    &amp;lt;a class=&amp;quot;modal&amp;quot; title=&amp;quot;'.JText::_('COM_LIBRARY_SELECT_BOOK_TITLE').'&amp;quot; href=&amp;quot;'.$link.&lt;br /&gt;
                         '&amp;quot; rel=&amp;quot;{handler: \'iframe\', size: {x:800, y:450}}&amp;quot;&amp;gt;'.&lt;br /&gt;
                         JText::_('COM_LIBRARY_BUTTON_SELECT_BOOK').'&amp;lt;/a&amp;gt;';&lt;br /&gt;
	  $html[] = '  &amp;lt;/div&amp;gt;';&lt;br /&gt;
	  $html[] = '&amp;lt;/div&amp;gt;';&lt;br /&gt;
	  &lt;br /&gt;
	  // The active book id field&lt;br /&gt;
	  if (0 == (int)$this-&amp;gt;value) {&lt;br /&gt;
		  $value = '';&lt;br /&gt;
	  } else {&lt;br /&gt;
		  $value = (int)$this-&amp;gt;value;&lt;br /&gt;
	  }&lt;br /&gt;
	  &lt;br /&gt;
	  // class='required' for client side validation&lt;br /&gt;
	  $class = '';&lt;br /&gt;
	  if ($this-&amp;gt;required) {&lt;br /&gt;
		  $class = ' class=&amp;quot;required modal-value&amp;quot;';&lt;br /&gt;
	  }&lt;br /&gt;
	  &lt;br /&gt;
	  $html[] = '&amp;lt;input type=&amp;quot;hidden&amp;quot; id=&amp;quot;'.$this-&amp;gt;id.'_id&amp;quot;'.$class.' name=&amp;quot;'.$this-&amp;gt;name.'&amp;quot; value=&amp;quot;'.$value.'&amp;quot; /&amp;gt;';&lt;br /&gt;
	  &lt;br /&gt;
	  return implode(&amp;quot;\n&amp;quot;, $html);&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Let's take a closer look at the method.   &lt;br /&gt;
* The modal behavior is loaded.&lt;br /&gt;
* The javascript function SelectBook_jform_request_id is defined and will be inserted into the &amp;lt;head&amp;gt; of the document with addScriptDeclaration().  Notice that $this-&amp;gt;id = jform_request_id.  'jform' is the form name given in the loadForm method in our model.  'request' reflects that this is a request field, and 'id' is the name of our field.&lt;br /&gt;
* There are several important points in the link that is created to open the modal window.  We include '''layout=modal''', as this will be an alternate list view layout for 'books'.  '''function=jSelectBook_.$this-&amp;gt;id''' will be used in the modal layout to identify the function to be called when a book is selected.&lt;br /&gt;
* Next, we obtain the title of the currently selected book from the database or return a generic &amp;quot;Select Book&amp;quot; phrase to be shown in the input field.&lt;br /&gt;
* The HTML output is created.  Note that this includes the hidden field that will have the id 'jform_request_id_id' and will accept the id value of the book selected in the modal window.&lt;br /&gt;
&lt;br /&gt;
== Update the view ==&lt;br /&gt;
Since we won't need a toolbar in the modal layout, we'll revise the books view.&lt;br /&gt;
'''''/administrator/components/com_library/views/books/view.html.php'''''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  public function display($tpl = null)&lt;br /&gt;
  {&lt;br /&gt;
	  // Get data from the model&lt;br /&gt;
	  $items = $this-&amp;gt;get('Items');&lt;br /&gt;
	  $pagination = $this-&amp;gt;get('Pagination');&lt;br /&gt;
	  $state = $this-&amp;gt;get('State');&lt;br /&gt;
	  &lt;br /&gt;
	  // Check for errors&lt;br /&gt;
	  if (count($errors = $this-&amp;gt;get('Errors'))) {&lt;br /&gt;
		  JError::raiseError(500, implode('&amp;lt;br /&amp;gt;', $errors));&lt;br /&gt;
		  return false;&lt;br /&gt;
	  }&lt;br /&gt;
	  &lt;br /&gt;
	  // Assign data to the view&lt;br /&gt;
	  $this-&amp;gt;items = $items;&lt;br /&gt;
	  $this-&amp;gt;pagination = $pagination;&lt;br /&gt;
	  $this-&amp;gt;state = $state;&lt;br /&gt;
	  &lt;br /&gt;
	  // Only set the toolbar if not modal&lt;br /&gt;
	  if ($this-&amp;gt;getLayout() !== 'modal') {&lt;br /&gt;
		  $this-&amp;gt;addToolBar();&lt;br /&gt;
	  }&lt;br /&gt;
	  &lt;br /&gt;
	  // Display the template&lt;br /&gt;
	  parent::display($tpl);&lt;br /&gt;
	  &lt;br /&gt;
	  // Set the document&lt;br /&gt;
	  $this-&amp;gt;setDocument();&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create the modal layout ==&lt;br /&gt;
When developers have had difficulty in implementing a modal form field, this is likely the step that is most commonly overlooked.  Creating a separate modal layout is necessary in order to include links with an onclick action that will call the SelectBook_jform_request_id function.  In many respects, this list view will mirror the default list view, but you may choose to leave out some columns such as the select checkboxes.&lt;br /&gt;
&lt;br /&gt;
Create the new file '''''/administrator/components/com_library/views/books/tmpl/modal.php'''''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 // No direct access&lt;br /&gt;
 defined('_JEXEC') or die('Restricted access');&lt;br /&gt;
 &lt;br /&gt;
 // Load tooltip behavior&lt;br /&gt;
 JHtml::_('behavior.tooltip');&lt;br /&gt;
 $listOrder	= $this-&amp;gt;escape($this-&amp;gt;state-&amp;gt;get('list.ordering'));&lt;br /&gt;
 $listDirn	= $this-&amp;gt;escape($this-&amp;gt;state-&amp;gt;get('list.direction'));&lt;br /&gt;
 &lt;br /&gt;
 $function = JRequest::getCmd('function', 'jSelectBook');&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo $this-&amp;gt;action; ?&amp;gt;&amp;quot; method=&amp;quot;post&amp;quot; name=&amp;quot;adminForm&amp;quot; id=&amp;quot;adminForm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;thead&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JHtml::_('grid.sort', 'COM_LIBRARY_BOOKS_HEADING_TITLE', 'title', $listDirn, $listOrder); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JHtml::_('grid.sort', 'COM_LIBRARY_BOOKS_HEADING_STATE', 'state', $listDirn, $listOrder); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JHtml::_('grid.sort', 'COM_LIBRARY_BOOKS_HEADING_HITS', 'hits', $listDirn, $listOrder); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JHtml::_('grid.sort', 'COM_LIBRARY_BOOKS_HEADING_CREATED', 'created', $listDirn, $listOrder); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JHtml::_('grid.sort', 'COM_LIBRARY_BOOKS_HEADING_MODIFIED', 'modified', $listDirn, $listOrder); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th width=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JHtml::_('grid.sort', 'COM_LIBRARY_BOOKS_HEADING_ID', 'id', $listDirn, $listOrder); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/thead&amp;gt;&lt;br /&gt;
    &amp;lt;tfoot&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td colspan=&amp;quot;6&amp;quot;&amp;gt;&amp;lt;?php echo $this-&amp;gt;pagination-&amp;gt;getListFooter(); ?&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/tfoot&amp;gt;&lt;br /&gt;
    &amp;lt;tbody&amp;gt;&lt;br /&gt;
&amp;lt;?php foreach ($this-&amp;gt;items as $i =&amp;gt; $item) : ?&amp;gt;&lt;br /&gt;
        &amp;lt;tr class=&amp;quot;row&amp;lt;?php echo $i % 2; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
                &amp;lt;a class=&amp;quot;pointer&amp;quot; onclick=&amp;quot;if (window.parent) window.parent.&amp;lt;?php echo $this-&amp;gt;escape($function);?&amp;gt;('&amp;lt;?php echo $item-&amp;gt;id; ?&amp;gt;', '&amp;lt;?php echo $this-&amp;gt;escape(addslashes($item-&amp;gt;title)); ?&amp;gt;');&amp;quot;&amp;gt;&amp;lt;?php echo $this-&amp;gt;escape($item-&amp;gt;title); ?&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;?php echo JHtml::_('jgrid.published', $item-&amp;gt;state, $i, 'books.'); ?&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;?php echo $item-&amp;gt;hits; ?&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;?php echo $item-&amp;gt;created; ?&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;?php echo $item-&amp;gt;modified; ?&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;?php echo $item-&amp;gt;id; ?&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;?php endforeach; ?&amp;gt;&lt;br /&gt;
    &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;boxchecked&amp;quot; value=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;filter_order&amp;quot; value=&amp;quot;&amp;lt;?php echo $listOrder; ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;filter_order_Dir&amp;quot; value=&amp;quot;&amp;lt;?php echo $listDirn; ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo JHtml::_('form.token'); ?&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This layout has two important differences when compared to the default layout.  &lt;br /&gt;
* We obtain the name of the javascript function using '''JRequest::getCmd('function', 'jSelectBook')'''.  &lt;br /&gt;
* The value of $function is then used in the onclick event on the title links.&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
[[User:radiant_tech|Denise McLaurin]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Form fields]]&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Joomla! 1.7]]&lt;/div&gt;</summary>
		<author><name>Radiant tech</name></author>	</entry>

	</feed>