Sunday, July 4, 2010

Content of form.php joomla part 4

We already discussed the behaviours of controllers in the last tutorial. Now it is time to learn the syntax of ‘form.php’ and ‘view.html.php’.

form.php use for both data insert and edit.

Here is the sample code of form.php
com_lanka1->views->lanka1->tmpl->form.php




<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
/**
* Lanka Map default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/
?>

<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col100">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>

<table class="admintable">

<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your name'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting" id="greeting" size="32" maxlength="250" value="<?php echo $this->lanka1->your_name;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your email'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting" id="greeting" size="32" maxlength="250" value="<?php echo $this->lanka1->your_email;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your TP'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting" id="greeting" size="32" maxlength="250" value="<?php echo $this->lanka1->your_tp;?>" />
</td>
</tr>
</table>
</fieldset>
</div>
<div class="clr"></div>

<input type="hidden" name="option" value="com_lanka1" />
<input type="hidden" name="id" value="<?php echo $this->lanka1->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="lanka" />
</form>






Not only form.php but also view.html.php is essential to success this stage
com_lanka1->views->lanka1->view.html.php




<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
* tp View
*
* @package Joomla.Tutorials
* @subpackage Components
*/

class Lanka1sViewLanka1 extends JView
{
/**
* display method of Hello view
* @return void
**/
function display($tpl = null)
{
//get the tp
$Lanka1 =& $this->get('Data');
$isNew = ($Lanka1->id < text =" $isNew">[ ' . $text.' ]' );
JToolBarHelper::save();
if ($isNew) {
JToolBarHelper::cancel();
} else {
// for existing items the button is renamed `close`
JToolBarHelper::cancel( 'cancel', 'Close' );
}

$this->assignRef('Lanka1', $Lanka1);

parent::display($tpl);
}
}


once you click edit/new button, It will go to following page



join with next

wAp

2 comments:

  1. ෂා........ මරුනේ...
    GooD WorK වැප්... :D

    ReplyDelete
  2. Man ur tutorial is awesome... keep up the good work !

    ReplyDelete